Java Interview Questions
Here, we are listing some essential Java Interview Questions for helping you in interview. The fundamental aspect of java programming language is Java Collections Framework. It is the one of the most important topic for Java interview. On this page, you will get collection of Advanced Java Interview Questions. We have also shared the most frequently asked Core java interview questions and answers for freshers& experienced candidates on this single web portal. Have a look below:
Java Collections Framework is helpful for the purpose of understanding and leverage many powerful features of Java. It is used in Java programming on all types of programs including web based and desktop applications.Java Collections Framework is main topic which will be asked in any Java interview. So, for the participants, we have provided basic java interview questionson this page, made by the team of recruitmentresult.com.
Java Interview Questions
Collection of Java Interview Questions
Ques01: What do you understand by Java?
- Java is an object-oriented computer language.
- It is a high-level programming language developed by James Gosling in Sun Microsystem in 1995.
- Java is a fast, secure and reliable language used for many games, devices and applications.
Ques02: Compare Java & Python:-
|Ease of use||Good||Very Good|
|Speed of coding||Average||Excellent|
|Data types||Static typed||Dynamically typed|
|Data Science & machine learning applications||Average||Very Good|
Want to Know? Java Interview Experience
Ques 03: Outline the major Java features.
|Object-Oriented||Java is based on object-oriented programming where the class and methods describe about the state and behavior of object.|
|Portable||Java program gets converted into Java Byte Codes that can be executed on any platform without any dependency.|
|Platform independent||java works on “write once and run anywhere” as it supports multiple platforms like Windows, Linux, Mac, Sun Solaris, etc.|
|Robust||Java has a strong memory management as there is no pointer allocations. It has automatic garbage collection that prohibits memory leaks.|
|Interpreted||java compiler converts the codes into Java Byte Codes which are then interpreted and executed by Java Interpreter.|
Ques04: What do you mean by Object?
Answer: An object consists of methods and class which depict its state and perform operations. A java program contains a lot of objects instructing each other their jobs. This concept is a part of core java.
Ques05: What is class in Java?
Answer: Java encapsulates the codes in various classes which define new data types. These new data types are used to create objects.
Want to Know? Interview Preparation Tips
Ques 06: Differentiate between JDK, JRE and JVM.
- JVM stands for Java Virtual Machine which provides runtime environment for Java Byte Codes to be executed.
- JRE (Java Runtime Environment) that includes sets of files required by JVM during runtime.
- JDK (Java Development Kit) consists of JRE along with the development tools required to write and execute a program.
Ques07: Define Inheritance.
Answer: Java includes the feature of inheritance which an object-oriented programming concept. Inheritance lets a derived class to inherit the methods of a base class.
Ques 08: Explain method overloading.
Answer: When a Java program contains more than one methods with the same name but different properties, then it is called method overloading.
Ques09: Compare Overloading and Overriding.
Answer: Overloading refers to the case of having two methods of same name but different properties, but overriding occurs when there are two methods of same name and properties, but one is in child class and one is in parent class.
Ques10:What is the difference between ArrayList and Vector?
|ArrayList is not synchronized.||Vector is synchronized.|
|ArrayList is not a legacy class.||Vector is a legacy class.|
|ArrayList increases its size by 50% of the array size.||Vector increases its size by doubling the array size.|
Ques11: Differentiate between StringBuffer and StringBuilder in Java programming.
|String Buffer||String Builder|
|StringBuffer methods are synchronized||StringBuilder is non synchronized|
|Storage area is Heap and modified easily.||Storage is Heap and can be modified.|
|StringBuffer is thread safe.||StringBuilder is fast as it is not thread safe|
|Performance is very slow||Performance is very fast.|
Ques12: Difference between Array list And Vector.
|Array List is not synchronized.||Vector is synchronized.|
|Array List is fast as it’s non-synchronized.||Vector is slow as it is thread safe.|
|If an element is inserted into the Array List, it increases its Array size by 50%.||Vector defaults to doubling size of its array.|
|Array List does not define the increment size.||Vector defines the increment size.|
|Array List can only use Iterator for traversing an Array List.||Except Hashtable, Vector is the only other class which uses both Enumeration and Iterator.|
Ques13: Differentiate between Iterator and Enumeration?
|Iterator is an interface found in the java.util package.||Enumeration is an object that generates elements one at a time. Used for passing through a collection for unknown size.|
|Uses 3 methods to interface such as:|
|Methods used are:|
|Iterators allow removing elements from the given collection during the iteration with well-defined semantics.||It is used for passing through a collection, usually of unknown size.|
|Iterator method names have been improved.||The traversing of elements can only be done once per creation|
Have a Look On Below Given Section
|Java Programming Ques & Ans||Vacancies For Java Freshers|
|Advanced Java Interview Ques & Ans||Advanced Java Syllabus|
|Core Java Syllabus||Core Java Interview Ques & Ans|
|Java Developer Salary In India||Career,Requires Coding Knowledge|
Ques 14: Difference between the Inner Class and Sub Class.
|Inner Class||Sub Class|
|It’s a class which is nested within another class.||It’s a class which inherits from another class called super class.|
|Inner class provides the access rights for the class which is nesting it and that can access all variables and methods defined in the outer class.||Sub-class provides access to all public and protected methods and fields of its super class.|
Ques15: Can we execute any code, even before the main method? Explain?
Answer: YES!!! We can execute any code because we are using a static block of code in the class at the time of creating the objects at load time of class. Along with any statements, this static block of code
Ques16: How can we restrict inheritance for a class?
Answer: We can restrict inheritance for class by following steps.
- By using final keyword
- If we make all method final, then we cannot override that.
- By using private constructors
- By using Javadoc comment (//)
Ques17:Name the core Collection interfaces…
How to Answer? Confusing Interview Questions
Ques18: What is the difference between HashMap and Hashtable?
|HashMap is not synchronized.||Hashtable is synchronized.|
|HashMap can contain one null key and multiple null values.||Hashtable cannot contain any null key or null value.|
Ques19: What are the advantages of JSON over XML?
Answer: The advantages of JSON over XML are
- JSON is Lighter and faster than XML
- Better understandable.
- Easy to parse and conversion to objects for information consumption
- Support multiple data types – JSON support string, number, array, Boolean but XML data are all strings
Ques20: Name the methods of Object Class?
- Clone () – This method helps to create and return a copy of the object.
- Equals() – This method helps to compare
- Finalize() – Called by the garbage collector on an object
- GetClass() – It helps to return the runtime class of an object.
- HashCode() – Helps to return a hash code value for the object.
- ToString() – helps to return a string representation of the object.
- Notify(), notifyAll(), and wait() – It helps to synchronize the activities of independently running threads in a program.
You may Read This: Interview Questions and Answers
HOPE!!! You all are satisfied from the above stated information regarding Java Interview Questions. If you have any confusion regarding this, you have facility to leave a comment in below given space. To get more updates, stay tined with this web page…