https://oliveiracoaching.com/slot-online/http://mednauki.ru/public/journals/1/slot-deposit-dana/https://www.trielht.com.br/libs/-/slot-gacor/https://windsoruniversity.us/slot-deposit-pulsa/https://www.limks ys.com/wp-content/uploads/2022/01/slot-deposit-dana/http://simpak.disdik.palembang.go.id/resources/slot-deposit-pulsa/index.phphttps://nusantarakini.com/wp-content/uploads/2022/-/slot-deposit-pulsa/https://bankvala.com/wp-content/uploads/slot-deposit-pulsa/https://eastchrist.tsu.ge/public/assets/slot-gacor/https://www.kecasaarredi.it/slot-deposit-pulsa/https://jobformazione.it/wp-content/utploads/slot-gacor-gampang-menang/https://www.exipurecomm.us/wp-content/uploads/2022/slot-gacor/https://perpustakaan.stikesnas.ac.id/files/slot-gacor/index.htmlhttps://undiknas.ac.id/wp-includes/pomo/slot-gacor/https://nusantarakini.com/wp-content/uploads/2022/-/slot-deposit-dana/https://travel2komiza.com/wp-content/uploads/2023/slot-deposit-dana/https://www.123hgh.com/include/slot-deposit-5000/https://www.pramukalumajang.or.id/media/files/judi-bola-online/https://agamaislam.ucm-si.ac.id/judi-sabung-ayam/https://ppln.kemlu.go.id/assets/foto/slot-deposit-dana/

Java Interview Questions

Shape Image One
Java Interview Questions

Java Interview Questions and Answers

Are Looking for Java Training? Learn Advanced Java training in Innovitt Global – . For More Details Call Now!

Java Interview Questions and Answers for beginners and experts. List of frequently asked Java Interview Questions with answers by Innovitt Global. We hope these Java interview questions and answers are useful and will help you to get the best job in the networking industry. These Java interview questions and answers are prepared by Java Professionals based on MNC Companies’ expectations. Stay tuned we will update New Java Interview questions with Answers Frequently. If you want to learn Practical Java Training then please go through this Java Training in Lucknow and Java Training in Uttar Pradesh

Best Java Interview Questions and Answers

Besant Technologies supports the students by providing Java interview questions and answers for job placements and job purposes. Java is the leading important course in the present situation because more job openings and the high salary pay for this Java and more related jobs. We provide Java online training also for all students around the world through the Online medium. These are top Java interview questions and answers, prepared by our institute experienced trainers.

Java interview questions and answers for the job placements

Here is the list of most frequently asked Java Interview Questions and Answers in technical interviews. These questions and answers are suitable for both freshers and experienced professionals at any level. The questions are for intermediate to somewhat advanced Java professionals, but even if you are just a beginner or fresher you should be able to understand the answers and explanations here we give.

Java interview questions and answers for Freshers and Experienced

Here I am providing some of the important core java interview questions with answers that you should know. You can bookmark this post to brush up your knowledge before heading for an interview. Whether you are a fresher or highly experienced professional, java plays a vital role in any Java/JEE interview. Java is the favorite area in most of the interviews and plays a crucial role in deciding the outcome of your interview. This post is about java interview questions that come directly from 10+ years of experienced Professionals of Java programming and lots of interviewing experience.

As a Java professional, it is essential to know the right buzzwords, learn the right technologies and prepare the right answers to commonly asked Java Interview Questions. Here’s a definitive list of top Java Interview Questions that will guarantee a breeze-through to the next level.

Q1) Why is Java known as the Platform Independent Programming Language?

The ease of executing the code on any platform makes this language a Platform Independent Programming Language. Just by installing JDK software on a system, JVM also gets installed automatically. This JVM (Java virtual machine) is the one that can execute Java bytecode. Each Java source file is compiled into a bytecode file, which is later executed by the JVM. Java was designed with a motto to allow the programs to be run on any platform, without the need of rewriting or compiling them each time recompile for different platforms.

Q2) Name the Data Types that are supported by Java?

There are 8 primitive data types that are supported by Java:

  • byte
  • int
  • short
  • long
  • float
  • double
  • char
  • boolean

Q3) Throw some light on the main features of Java.

  • Object-Oriented language– First and foremost feature of Java. By object-oriented means here the state and behavior of an object is described by the class and the methods.
  • Platform independent language – Java runs on the WORA principle. WORA means “Write Once Run Anywhere”. Java was mainly designed to support platform independency. Thereby Java supports multiple platforms like Windows, Mac, Linux, Sun Solaris, etc.
  • Portable – It means Java byte code can be run on any hardware that is JVM compliant.
  • Robust – It is a highly supported language. It has a strong memory management and the reason is that there are no pointer allocations.
  • Prohibits Memory Leaks – Java is having automatic garbage collection feature that stops the memory leakage.

Q4) Define Autoboxing and Unboxing?

Autoboxing is an automatic conversion which is made by the Java compiler. The conversion of a primitive type to the equivalent reference type is termed as Autoboxing. Conversion of a double to a Double, an int to an Integer, etc are examples of Autoboxing. We can simply call it boxing too. Unboxing is the opposite of Boxing, i.e., conversion of the reference type to the corresponding primitive type such as Byte to byte.

Q5) What is Overloading and Overriding in Java?

Overloading: When two or more methods in the same class having exactly the same name, but parameters are different then it is called Method overloading. It is a compile-time concept. Overriding: When a child class redefines the same method as that of in a parent class, then it is called Method overriding. Polymorphism is applicable for overriding, and not for overloading. It is a run-time concept.

Java training in Lucknow

Q6) How do you differentiate a HashSet class and a TreeSet class?

HashSet Class – It implements java.util.Set interface.

  • It eliminates the duplicate entries and it makes use of hashing for storage.
  • Hashing is the mapping between a key value and a data item. This way it provides the efficient searching of data.
  • TreeSet Class – It implements java.util.Set interface.
  • It provides an ordered set and this class uses tree for storage purpose.
  • Like Hashset class, this also eliminates the duplicate entries.

Q7) What is a List? What is the difference between an ArrayList and a LinkedList?

List is a collection of non-duplicate objects which are in an order. One can access the elements of a list in a specific order.

  • An ArrayList Class implements java.util.List interface and for storage it uses arrays, while a LinkedList class also implements java.util.List interface but uses linked list for storage.
  • Storage in arrays is faster than List.
  • The insertion and deletion of elements can’t be done in the middle of an ArrayList. To achieve this, a new array needs to be constructed. But in case of LinkedList, elements can be added and deleted from anywhere in the list.

Q8) Define JVM, JDK and JRE?

  • JVM stands for Java Virtual Machine. JVM is a process execution machine that provides the runtime environment in which the java byte code can be executed.
  • It is platform dependent because JVMs are available for almost all hardware and software platforms.
  • JDK stands for Java Development Kit. It so physically exists. It is for writing Java applets and applications The runtime environment of JDK sits on the top of the operating system.
  • JRE is an acronym for Java Runtime Environment. It is also known as Java Runtime. It is a part of JDK. It is a set of programming tools used for developing the Java applications.

Q9) Define the Java’s WORA nature?

WORA means Write Once Run Anywhere. Java is compiled to a bytecode which does not platform specific. This bytecode is the intermediate language between the source code and the machine code. As the bytecode is not platforming specific, so it can be used to any platform. Sometimes, it is also called WORE – Write Once Run Everywhere.

Q10) How do you differentiate between StringBuffer & StringBuilder?

  • StringBuffer is thread safe, which means it is synchronized. Two methods at the same time can’t call the methods of StringBuffer. On the other hand, StringBuilder is non-synchronized. So two methods can simultaneously call the methods of StringBuilder.
  • StringBuffer is less efficient when compared to StringBuilder.

Q11) What is the case when you override hashcode() and equals() ? What problem can occur if we don’t override hashcode() method?

We can override hashcode and equals whenever necessary. Especially the case when one wants to do equality check or to use one’s object as a key in HashMap. If we don’t override hashcode() method, we’ll not be able to recover our object from hashMap (if that is used as a key in HashMap).

Q12) What are immutable classes?

An Immutable class is a Java class whose objects cannot be modified once created. Any alteration in the Immutable object results into a new object. All the java.lang package wrapper classes are immutable. Examples are: Short, Long, Boolean, String, etc.

Q13) Mention the access specifiers used in Java?

Access specifiers are defined as the keywords that are used before a class name which defines the scope of accessing. The types of access specifiers are:

  • Public – Class, Methods and Fields are accessible from anywhere.
  • Private – Methods and Fields can be accessed only from the same class to which they actually belong.
  • Protected – Methods and Fields can be accessed from the same class to which they belong, from the sub-classes and also from the classes of same package. But they are not accessible from outside.
  • Default – Methods, Fields, classes can only be accessible from the same package, not from outside.

Q14) What is Singleton in Java?

Singleton is a class with only one instance in the whole Java application. For an example java.lang.Runtime is a Singleton class. The prime objective of Singleton is to control the object creation by keeping the private constructor.

Q15) Will all the Try blocks in Java end with Catch Blocks?

Yes, Try block either needs to be followed by Catch block or by Finally block or sometimes by both. The reason is that any exception that will be thrown from a try block needs to be caught in a catch block, and even if no exception is there then also use of Finally block should be there so as to specify any specific tasks that need to be performed before code ends.

Q16) What is the Final Keyword in Java?

In Java, Final the keyword is used to declare a constant. A value can be assigned only once to a constant. Later, the value can’t be changed. Example: Private Final int const_val=50 Here constant is assigned the value 50. The method here is resolved at complied time, thus are faster than any other code.

Q17) Is it possible to declare a class as Abstract without using any abstract method?

Yes, this case is possible. We can create an abstract class by using the abstract keyword before the class name. Also, even if a class has one or more abstract methods, then also, it must be declared as abstract, else it will throw error

Q18) Any five differences between an Abstract Class and Interface in Java?

  • Where an abstract class have a limit to extent only one class or abstract class at a time, Interface has no such limits. It can extend n numbers of interfaces at the same time.
  • Abstract classes can have both abstract as well concrete methods. On the other hand, interface can only have abstract methods.
  • Abstract class can provide complete code, but interface can only provide signature, not the code.
  • Speed wise Abstract classes are faster than interfaces.
  • An abstract class can have public and protected abstract methods while Interface, by default, can have only public abstract methods.

Q19) Define Serialization? When should we make use of serialization?

Serialization – It is a way of writing an object’s state into a byte stream. This converted byte stream is transferred on the network and the object is then re-created at the destination. Implementation of java.io.Serializable the interface is must if you want to serialize a class’ object. Serialization is basically used when data needs to be transmitted over the network. This traveling of state of an object on the network is known as marshaling.

Q20) Explain multi-threading and the ways of implementing multi-threading in Java?

Multithreading is a concept of running multiple tasks in a concurrent manner in a single program. The threads

shares the same process stack and thus runs in parallel. This process helps in improving the performance of a program. Multi-threading can be implemented in two ways:

  • First is by the use of Java.Lang.Runnable Interface.
  • Another ways is to write a class that extends the Java.Lang.Thread class.

Q21) What is Collection and a Collections Framework?

Collection: A collection is an object for grouping multiple elements into a single unit. It can hold other objects’ references. Collections are also termed as the container

Collections Framework: It provides an architecture that stores, manipulates and represents collections. It is a collection of classes and interfaces. Advantages of Collections Framework:

  • Improves program speed and quality
  • helps in storing & processing the data efficiently
  • Decreases the programming effort and increases the reusability chances of a software.

Q22) What do you mean by BlockingQueue in Java Collections Framework?

It implements the java.util.Queue interface and supports the operations that wait for space availability in the queue while storing an element. Blocking queues are mainly designed keeping the consumer-producer problems in mind. BlockingQueue does not accept the null elements. Also they are used in inter-thread communications.

Q23) What is the difference between ArrayList and Vector?

  • ArrayList is faster than Vector.
  • ArrayList is introduced in JDK 1.2. It is therefore not a legacy class, but Vector is.
  • To traverse the elements, an ArrayList uses Iterator interface while Vector can use Iterator as well as Enumeration interface.
  • Unlike ArrayList, Vector is synchronized.

Q24) Define Constructor and Constructor Overloading in Java.

Constructor – It gets invoked automatically when a new object is created. Every class has a constructor, so even if one forgot to mention it, the Java compiler itself creates a default constructor for that class. Constructor is like a method that doesn’t return the type. Constructor overloading – It is same as method overloading. Same constructor with different parameters can be declared in the same class. Then it’s the role of compiler to differentiate which constructor needs to be called depending upon the parameters and the sequence of data types.

Q25) What are the differences between Enumeration and Iterator?

  • When it comes to traversing the elements, Enumeration can do only legacy elements unlike Iterator that can traverse both legacy as well as non-legacy elements.
  • Enumeration interface don’t have remove() method which is there in Iterator.
  • Enumeration is less safer than Iterator.
  • Enumeration is fail-safe while Iterator is fail-fast.

Q26) Why break is used in Switch Statement’s each case?

Break is used in a switch so that code breaks after the valid case and thus prevents the flowing of code in the cases too. If break isn’t used after each case (except the last one), a wrong result will generate as it will execute all the proceeding cases after the valid case.

Q27) Name the different states of a thread.

An independent path of execution in a program is called as Thread. There are several states of a thread:

  • Ready: When a thread is created, it is said to be in the Ready state.
  • Running: The thread that is currently being executed is said to be in running state.
  • Waiting: Awaiting state is a state when a thread that is waiting for another thread to free certain resources so that it can acquire those resources.
  • Dead: A thread whose run() method exits is in dead or terminated state.

Q28) Is it true that a java program never goes out of memory because of garbage collection feature?

No this is not a true case. Automatic garbage collection can help in reducing the chances but can’t eradicates the possibility fully. It doesn’t ensure that a Java program will never go out of memory. There is a possibility that objects are created at a faster pace than that of garbage collection. This results into the filling of all the available memory resources, thus memory goes out of leak.

Q29) How can you define Object Cloning in Java?

Creating an exact copy of an object is known as the object cloning. clone() method of object class and java.lang.Cloneable interface are used for this purpose. If we don’t use mentioned interface(Cloneable interface), the clone() method will generate the CloneNotSupportedException. Cloning is a fastest way to copy the arrays. Also cloning takes less lines of code.

Q30) Is throw and throws keyword can be used interchangeably? If no, what is the difference between the two?

No, these two are different keywords, thus can’t be used interchangeably. Following are the differences between the two!:

  • The throw is used for throwing an exception while Throws used for declaring an exception.
  • Throw followed by an instance, whereas throws followed by a class.
  • With throw, one cannot throw multiple exceptions, but with Throws, multiple exceptions can be declared.
  • Throw is used in method body, but Throws is used in the method declaration which is signature.

Q31.What is the difference between JDK, JRE, and JVM?

JVM is an acronym for Java Virtual Machine, it is an abstract machine which provides the runtime environment in which Java bytecode can be executed. It is a specification.

  • JVMs are available for many hardware and software platforms (so JVM is platform dependent).
  • JRE stands for Java Runtime Environment. It is the implementation of JVM.
  • JDK is an acronym for Java Development Kit. It physically exists. It contains JRE + development tools.

Q32) What is the difference between an Inner Class and a Sub-Class?

An Inner class is a class which is nested within another class. An Inner class has access rights for the class which is nesting it and it can access all variables and methods defined in the outer class.

A sub-class is a class which inherits from another class called superclass. Sub-class can access all public and protected methods and fields of its superclass.

Q33) What is Final Keyword in Java? Give an example.

In Java, a constant is declared using the keyword Final. Value can be assigned only once and after assignment, a value of a constant can’t be changed.

  • In below example, a constant with the name const_val is declared and assigned a value
  • Private Final int const_val=100
  • When a method is declared as final, it can NOT  be overridden by the subclasses.This method is faster than any other method because they are resolved at the compiled time.
  • When a class is declared as final, it cannot be subclassed. Example String, Integer, and other wrapper classes.

Q34) What’s the base class in Java from which all classes are derived?

  • lang.object

Q35) What’s the difference between an Abstract Class and Interface in Java?

The primary difference between an abstract class and interface is that an interface can only possess declaration of public static methods with no concrete implementation while an abstract class can have members with any access specifiers (public, private etc) with or without concrete implementation.

Another key difference in the use of abstract classes and interfaces is that a class which implements an interface [su_spoiler title=”must implement all the methods of the interface while a class which inherits from an abstract class doesn’t require implementation of all the methods of its superclass.

A class can implement multiple interfaces but it can extend only one abstract class.

Q36) What is a platform?

A platform is basically the hardware or software environment in which a program runs. There are two types of platforms software-based and hardware-based. Java provides the software-based platform.

Q37) What is classloader?

The classloader is a subsystem of JVM that is used to load classes and interfaces.There are many types of classloaders e.g. Bootstrap classloader, Extension classloader, System classloader, Plugin classloader etc.

Q38) What is the static method?

  • A static method belongs to the class rather than an object of a class.
  • A static method can be invoked without the need for creating an instance of a class.
  • A static method can access static data member and can change the value of it.

Q39) Can a class have multiple constructors?

Yes, a class can have multiple constructors with different parameters. Which constructor gets used for object creation depends on the arguments passed while creating the objects.

Q40) What’s the difference between an array and Vector?

An array groups data of same primitive type and is static in nature while vectors are dynamic in nature and can hold data of different data types.

Q41) What are the two ways of implementing multi-threading in Java?

Multi-threaded applications can be developed in Java by using any of the following two methodologies

  1. By using Java.Lang.Runnable Interface. Classes implement this interface to enable multithreading. There is a Run() method in this interface which is implemented.
  1. By writing a class that extends Java.Lang.Thread class.

Q42) How can we execute any code even before the main method?

If we want to execute any statements before the even creation of objects at load time of class, we can use a static block of code in the class. Any statements inside this static block of code will get executed once at the time of loading the class even before the creation of objects in the main method.

Q43) What’s the benefit of using inheritance a key?

Key the benefit of using inheritance is reusability of code as inheritance enables sub-classes to reuse the code of its super class. Polymorphism (Extensibility ) is another great benefit which allow new functionality to be introduced without effecting existing derived classes.

Q44) What’s the difference between Stack and Queue?

Stack and Queue both are used as placeholder for a collection of data. The primary difference between a stack and a queue is that stack is based on Last in First out (LIFO) principle while a queue is based on FIFO (First In First Out) principle.

Q45) Which types of exceptions are caught at compile time?

Checked exceptions can be caught at the time of program compilation. Checked exceptions must be handled by using try catch block in the code in order to successfully compile the code.

Q46) Is String a data type in java?

String is not a primitive data type in java. When a string is created in java, it’s actually an object of Java.Lang.String class that gets created. After creation of this string object, all built-in methods of String class can be used on the string object.

Q47) List any five features of Java?

Some features include Object Oriented, Platform Independent, Robust, Interpreted, Multi-threaded

Q48) Why are Strings in Java called as Immutable?

In Java, string objects are called immutable as once the value has been assigned to a string, it can’t be changed and if changed, a new object is created. In below example, reference str refers to a string object having value“Value one”.

Q49) What’s the difference between an array and Vector?

An array groups data of same primitive type and is static in nature while vectors are dynamic in nature and can hold data of different data types.

Q50) Why Java is considered dynamic?

It is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.

Q51) Define class?

A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object.

Q52) How would you call wait() method? Would you use if block or loop, and why?

wait() method should always be called in loop. It is likely that, until thread gets CPU to start running again, the condition may not hold. Therefore, it is always advised to check condition in loop before continuing.

Q53) How do you take thread dump in Java?

By using kill -3 PID in Linux, where PID is the process id of Java process, you are able to take a thread dump of Java application. In Windows, you can press Ctrl + Break.

Q54) What is the difference between sleep and wait in Java?

Both are used to pause thread that is currently running, however, sleep() is meant for short pause because it does not release lock, while wait() is meant for conditional wait.This is why it releasesm lock, which can then be developed by a different thread to alter the condition of which it is waiting.

Q55) Is ++ operator thread-safe in Java?

++ is not thread-safe in Java because it involves multiple commands such as reading a value, implicating it, and then storing it back into memory.

Q56) What is constructor chaining in Java?

Constructor chaining in Java is when you call one constructor from another. This generally occurs when you have multiple, overloaded constructor in the class.

Q57) Explain Java Heap Space and Garbage collection.

When a Java process has started using Java command, memory is distributed to it. Part of this memory is used to build heap space, which is used to assign memory to objects every time they are formed in the program.

Part of this memory is used to build heap space, which is used to assign memory to objects every time they are formed in the program.

Garbage collection is the procedure inside JVM which reclaims memory from dead objects for future distribution.

Q58) What is the difference between final, finalize and finally?

  • Final is a modifier which you can apply to variable, methods, and classes. If you create a variable final, this me its value cannot be changed once initialized.
  • Finalize is a method, which is called just before an object is a garbage collected, allowing it a final chance to save itself, but the call to finalize is not definite.
  • Finally is a keyword which is used in exception handling, along with try and catch. The finally block is always implemented regardless of whether an exception is thrown from try block or not.

Q59) What is the difference between poll() and remove() method?

Both poll() and remove() take out the object from the Queue but if poll() fails, then it returns null. However, if remove() fails, it throws exception.

Q60) What kind of variables can a class consist of?

A class consists of the Local variable, instance variables, and class variables.

Q61) What is Singleton class?

ingleton class control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes.

Q62) List the three steps for creating an Object for a class?

An Object is first declared, then instantiated and then it is initialized.

Q63) When a byte datatype is used?

This data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int.

Q64) What do you mean by Access Modifier?

Java provides access modifiers to set access levels for classes, variables, methods and constructors. A member has

package or default accessibility when no accessibility modifier is specified.

Q65) When parseInt() method can be used?

This method is used to get the primitive data type of a certain String.

Q66) Why is StringBuffer called mutable?

The String class is considered as immutable, so that once it is created a String object cannot be changed. If there is a necessity to make alot of modifications to Strings of characters then StringBuffer should be used.

Q67) What is an Exception?

An exception is a problem that arises during the execution of a program. Exceptions are caught by handlers positioned along the thread’s method invocation stack.

Q68) When throw keyword is used?

An exception can be thrown, either a newly instantiated one or an exception that you just caught, by using throw keyword.

Q69) When a super keyword is used?

If the method overrides one of its superclass’s methods, overridden the method can be invoked through the use of the keyword super. It can be also used to refer to a hidden field.

Q70) Why Runnable Interface is used in Java?

Runnable interface is used in java for implementing multi-threaded applications. Java.Lang. Runnable the interface is implemented by a class to support multi-threading.

Q71) What’s the purpose of using Break in each case of Switch Statement?

Break is used after each case (except the last one) in a switch so that code breaks after the valid case and doesn’t flow in the proceeding cases too.

Q72) How we can execute any code even before main method?

If we want to execute any statements before even creation of objects at load time of class, we can use a static block of code in the class. Any statements inside this static block of code will get executed once at the time of loading the class even before creation of objects in the main method.

Q73) Can we have two methods in a class with the same name?

We can define two methods in a class with the same name but with different number/type of parameters. Which method is to get invoked will depend upon the parameters passed.

Q74) How can we make the copy of a Java object?

We can use the concept of cloning to create copy of an object. Using clone, we create copies with the actual state of an object. lone() is a method of Cloneable interface and hence, Cloneable interface needs to be implemented for making object copies. 45. In Java, how we can disallow serialization of variables? If we want certain variables of a class not to be serialized, we can use the keyword trient while declaring them.

Q75) Which types of exceptions are caught at compile time?

Checked exceptions can be caught at the time of program compilation. Checked exceptions must be handled by using

try-catch block in the code in order to successfully compile the code.

Q76) Can we use a default constructor of a class even if an explicit constructor is defined?

Java provides a default no argument constructor if no explicit constructor is defined in a Java class. But if an explicit constructor has been defined, default constructor can’t be invoked and the developer can use only those constructors which are defined in the class.

Q77) Can we override a method by using same method name and arguments but different return types?

The basic condition of method overriding is that method name, arguments, as well are turn type must be exactly same as is that of the method being overridden.  Hence using a different return type doesn’t override a method.

Q78) What is an applet?

An applet is a Java program that runs in a Web browser. An applet can be a fully functional Java application because it has the entire Java zPI at its disposal.

Q79) What is Comparable Interface?

It is used to sort collections and arrays of objects using the Collections.sort() and java.utils. The objects of the class implementing the Comparable interface can be ordered.

Q80) Why IS Java application platform independent?

In Java application first, java compiler convert our java source code to bytecode. This bytecode sends or through any OS or hard disk or something, it’s accepted directly in using of JVM.Each JVM worked based on own platform, but all JVM accept machine language(of byte stream) easily.so only java application called platform independent.

Q81) What are the actions present in the JVM?

1.Loader-it performed to collect the codes anywhere(hard disk or software or ide)to given JVM.

2.Compiler-to converts source code to bytecode.

3.Jit-to covert bytecode to a high-level language.

4.Execution-finally program starts to run and execute the output.

Q82) What is the current version of JDK?

JDK-java development kit current version is 1.8.

Q83) Java is fully OOPS language or not?

No, its present primitive(old datatypes).so java not fully based on OOPS.

Q84) What is Wrapper class?

Wrapper class means typecasting (to convert one data type to another data type).this class used to data objects(Integer, Float, Char, Byte, Short, Long, Double, Boolean).

Q85) What is an Immutable class?

Once create the value of class cannot be modified, that class called immutable class.immutable class present 9 classes and there are 8 wrapper class and string class, totally present 9 immutable class.

Q86) What is Array?

Array means collection of similar data types.its present two types.

1.single dimension-stored multiple value in single variable.

ex: int a[]={1,2,3,4};

2.multi dimension-values stored based on rows and columns.

ex: int a[][]={{1,2,3},{1,2,3},{1,2,3}};

Q87) What is String?Difference between StringBuilder and StrinngBuffer?

String means a collection of characters.It’s used to get any data type values(Like int, char, float,etc..).so string act as strong media.

String value once creates cannot be modified so only we prepared next level of StringBuilder and StrinngBuffer.

StringBuilder-it’s a non-synchronized method so it’s acting very fast and no thread safe.

StrinngBuffer-it’s a synchronized method so it’s acting slow and thread safe.

Q88) What is Function?

Function means member function and smallest multiple blocks of class.the function only can be access to provide calling function, otherwise cannot be accessed.

Q89) What is Class?

It’s a templet or blueprint or collection of objects .its describe state and behaviors .state means-data, behavior means-method.

Q90) What is Object?

It’s a runtime or real-time entities.each object gets own properties and response.objects are used to access the class properties.

Q91) What is Polymorphism?

One object or message functioned different actions called polymorphism.

Q92) What is Function Overloading?

Using a number of same method name and different parameters in a single class to achieve this process polymorphism its known as function overloading.

Q93) What is Function Overriding?

Using same method name and same parameters in inheritance method to override parent on child class details, it is called function overriding.

Q94) Why used super and this keyword in java?

this keyword means-current or represent a class.its used to read current class properties.

super keyword means-super or parent class.its used to read immediate parent class properties.

Q95) What is inheritance?

One class of data or properties collected or send in another class is called inheritance.

Q96) Describe the types of Inheritance?

1.single-one parent to one child class.

2.multilevel-one parent to child, after that child act as a parent, to send another child.

3.hierarchical-one parent to any child.

4.multiple-two parent send at a time one child.

5.hybrid-combination of hierarchical and multiple.

Q97) What is scope?Describe the types of scope?

scope means storage capacity or level of variable and methods.

1.package scope-this variable or method storage present within a package otherwise its destroyed.

2.class scope-its present within the class otherwise, it’s destroyed.

3.method scope-its present the method otherwise, it’s destroyed.

4.block scope-its present within the block otherwise, it’s destroyed.

Q98) Types of Access Specifiers?

1.public-its global value, accessed package to package.

2.private-its private value, accessed only within the class.

3.protected- its used inheritance class, its possible only hierarchical inheritance.

4.default- its normal type, its used within the package.

Q99) What is Encapsulation?

Binding or warping to the data and method within a class is called encapsulation.

Q100) What is Abstraction?

Hiding the background details and show only essential features or functions.this is advance of an interface.

Q101) What is Multitasking? How to achieve multitasking?

Different network performed a different task called multitasking.to achieve this process using two concepts

1.multi threading

2.multi processing

Q102) What is Thread?

A single core of sequential process called thread.

ex: single desktop application.

Q103) what is Multithreading?

Multiple actions performed sequentially at a time is called multithreading.

ex: atm process

Q104) Difference between Multithreading and Multiprocessing?

Multi processing-no allocation of the common memory in a set of process, so speed low, high cost.

Multi threading-multi threading allocates common memory in a set of threading, so high speed, low cost.

Q105) What is Interface?

The interface in java is a mechanism to achieve abstraction.There can be only abstract methods in the Java interface, not method body.

It is used to achieve abstraction and multiple inheritances in Java. and also a blueprint of class.

Q106) Difference between Interface and Abstraction?

Abstraction-using abstract keyword must.itsused to not achieve multiple and hybrid inheritance.

Interface-abstract keyword not must.its used to achieve multiple and hybrid inheritance.

* The abstract class cannot implement one interface, but one interface implements to one abstract class.

Q107) What is Serialization?

In our source code converted into a byte stream(machine understanding language) this process called Serialization.it’s means to write the objects (of data) in the needed destination.so we are using output streams of write objects.

Q108) What is DeSerialization?

In our byte stream convert into a high-level language(human being understanding language) this process called deSerialization.its mean read the objects (of data) in a needed platform.so we are using input streams of reading objects.

Q109) What is Exception?types of Exception?

The exception is an abnormal condition.In Java, an exception is an event that disrupts the normal flow of the program.

It is an object which is thrown at runtime.

types

1.error-its irrecoverable.

2.checked exception-compile time error.

3.un checked exception-run time error.

Q110) Explain Exception Handling methods?

Any exception occurred in our source code the compiler terminated or skip the process, so that place we are using Exception Handling.

it means to catch and handle the exception, to maintain the flow of process normally.some methods

1.Try-it used to catch the exception.

2.Catch-it used to handle the exception.

3.Finally-finally block executes always.

4.throw-it used to create exception explicitly.

5.throws-its indicate signature of methods for handling the exception.

Q111) What is Java ?

Java is a programming language used to create programs that is used to perform the tasks.

Q112) Which thread will execute first?

Main() thread will start first

Q113) How to achieve lock?

By using synchronized keyword you can achieve lock.

Q114) How to get the current thread?

By using Thread.currentThread() method

Q115) Difference between Array and Arraylist?

  1. Array
  2. It is fixed size
  3. Arraylist
  4. Its not fixed size, dynamically grows and shrinks.
  5. Array
  6. Does not provide built in methods
  7. Arraylist

Provides built in methods to add,delete

Q116) How to sort the collections?

Collections.sort() method we can use to sort

Q117) Which data structure set uses?

Set internally uses map data structure.

Q118) Is wrapper classes overrides hashcode and equals method.

Yes

Q119) What is Treeset?

Set with sorted elements.

Q120) In which scenarios Arraylist and LinkedList will be used?

For searching Arraylist is will be used and for modification linkedlist will be used.

Q121) What happens if you add same key in the hashmap?

Key will remain same, It will override the value.

Q122) Can we add null key to the hashmap?

Yes hashmap allows only one null key

Q123) Hashmap put() operations uses which datastrcture when the hashcode is same ?

It uses Linkedlist data structure.

Q124) Does java 8 supports functional programming?

Yes. By using lambda expressions.

Q125. What is default method in java 8 interface?

Java 8 interface allows one method implementation as default by using default keyword.

Q126) Difference between stringbuffer and stringbuilder?

Stringbuffer is a synchronized

Stringbuilder is not synchronized.

Q127) What is token in c

Small individual units of program call token.

Q128) What is keywords, data type, constant and variable

Keywords: Its reserved which have special meaning provided by compiler.

Data type: Its define the type of variable. There are four fundamental data type in c

Int->integer value

Float-> Float value

Char->character value

Double->for double value

Constant: its means fixed. Once a variable has declared as a constant,the value of variable can not change through out the program. const keywords use to declare variable as contant.

Variable: it’s a identifier which use to hold the value in program.

Q129) What are the fundamental data type in c

there are seven fundamental data type in c

  • Arithmetic Operator
  • Logical Operator
  • Relational Operator
  • Assignment Operator
  • Increment or decrement Operator
  • bitwise Operator
  • ternary or conditional operator

Q130) What are the conditional statement

conditional statement are:

  • if
  • if-else
  • nested if-else
  • else-if ladder
  • switch-case

Q131) What are the un-conditional statement

un conditional statement are:

  • break
  • continue
  • goto
  • exit()

Q132) What is if—else statement

in if—else statement either if block will work or else block will wor, both cant work together. If condition is true if block will work other wise else block will work.

Syntax:

if(condition)

{

//statement;

}

else

{

//statement;

}

Q133) What is switch case statements

its is use for multiple value checking.

Syntax:

Switch(expression)

{

Case 1: //statement

break;

Case 2: //statement

break;

Case 3: //statement

break;

.

.

default:

}

Q134) What is conditional operator

its shortest form of if-else.its  is called as ternary operator.

Syntax:

Expression?value1: value2;

If expression is true it return value1 otherwise vlaue2.

Q135) What are the iterative statement

Iterative statement are:

  • while
  • do-while
  • for

Q136) What is an array

Array is the collection of homogenous data elements.

Syntax:

int Array_name(size);

Q137) What is sorting

sorting is technique in which we arrange dtata in either ascending or descending order.

Some techniques are:

  • bubble sort
  • selcstion sort
  • insertion sort
  • quick sort
  • merge sort

Q138) What is searching

searching is a technique through which  we can search a particular elements.

Some searching techniques are:

  • linear search
  • binary serch

Q139) What is function

it’s a set of statement to perform specific task.

Syntax of user define function:

Returntype function_name(datatype1 param1,datetype2  param2,….)

{

//set of statements

return(value);

}

Q140) Explain the type of user define function

there are four type of user define function

  • function without parameter without return type.
  • function without parameter with return type.
  • function with parameter without return type.
  • function with parameter with return type.

Q141) What is recursive function

function call itself again and again is called recursive function

Syntax:

Function_name

{

//statements

Function_name();

}

Q142) What is structure

it is the collection of non-homogenous data element.

Syntax:

stuct structure_name

{

Datatype1  varaiable1;

Datatype2  varaiable2;

.

.

};

struct structure_name Variable_name;

Q143. What is difference

between structure and union” open=”no” style=”default” icon=”plus” anchor=”” class=””]

the major difference between structure and union is

In structure each member variables have individual memory allocation where as in union  member variable share memory allocation.

Q144. What is pre-processor directive

pre-processor directive start with # and it work before compilation

Example:#include,#define,#if,#prgma,#error etc

Q145. What is micro in c

micro can be define before main() function

Syntax:

#define x 6

Q146. What is file

it is collection of data or information, store permanently in our system.

Q147. What is file pointer

if we want to write or retrieve data from the file that is possible only with help of file pointer.file pointer can be declared as

File *File_pointer_name;

Q148. What is data structure

it’s a sequence of data through which we can easily perform operation like insert, search and delete

Q149. What is stack

its is non-primitive linear data structure work on LIFO(last in first out) technology.it is use in conversion of expression, scientific calculation etc.

Q150. What is queue

its is non-primitive linear data structure work on FIFO(First in first out) technology.it is use in Railway reservation system, online ordersystem  etc.

Future-Proof Your Career with the Latest In-Demand Courses
Apply Now & Start Learning
Future-Proof Your Career with the Latest In-Demand Courses
Apply Now & Start Learning
Apply Now & Start Learning