Java Interview Questions
0 3418
Java has been one of the most popular programming languages that are used to develop around 15 billion devices worldwide.
The reason I choose Java as my career is due to its extensibility, ease of use, platform independence, and modularity.
In this blog, I will enlist some of the Java Interview Questions which I faced during my Interview and which I ask the applicants as an interviewer.
These questions will not only help you enhance your Java knowledge base but will also set you apart in the interview.
Let's proceed!
1) What are JDK, JRE and JVM?
Java Development Kit (JDK) is a tool used for compiling, documenting and packaging Java programs.
Java Runtime Environment (JRE) is the runtime environment that is used to run Java code.
Java Virtual Machine (JVM) is an abstract runtime environment that is used to run Java code.
2) Enlist some of the features of Java.
Some of the popular features of Java are:
- OOPS Concepts.
i) Object-oriented
ii) Inheritance
iii) Encapsulation
iv) Polymorphism
v) Abstraction
- Platform Independence
- Multi-threaded
- High Performance
3) Name some of the Java IDE's.
Some of the Java IDE's are:
- NetBeans
- Eclipse
- Intellij IDEA
- JDeveloper
- DrJava
4) What is a constructor in Java?
A constructor in Java is a special method of a class that is used to initialize an object having the same type.
It consists of the same type as the class and is used to set the value for the member of the class, to either default or user-defined value.
5) What is the difference between a local variable and an instance variable?
A local variable is a variable that is defined inside the method and the scope of the variable exists within the method only.
On the other hand, an instance variable is defined within a class & outside the method. The scope of an instance variable is throughout the class.
6) What do you mean by a class in Java?
A class is an object defined prototype in Java which is used to create objects having the same type and a similar set of properties and methods.
7) What is an object?
An object in Java is an instance of a class that consists of real values. An object in Java can be defined as the accumulation of all the procedures and data involved in the programming.
8) What is inheritance in Java?
Inheritance is an important concept of OOPS where one class inherits the properties of another class. The class which beholds the properties to be inherited is known as the parent class whereas the class which inherits the properties of the parent class is known as the child class.
The child class can also add some extra methods and properties apart from inherited properties.
9) What is encapsulation?
As the name suggests, encapsulation refers to the process of embedding the codes and methods altogether in a capsule that can be used for the programming at once.
One of the best examples of encapsulation in Java is the Java Bean Class.
10) What is polymorphism?
Polymorphism is an OOPS concept which defines that an object can take multiple forms. There are two types of polymorphism in Java:
a) Compile-time Polymorphism done by method overloading
b) Runtime Polymorphism by method overriding
11) What is method overriding and overloading?
Method overloading occurs when two methods in a class have the same method name but varied parameters.
On the other hand, method overriding occurs when two methods have the same method name as well as parameters; and while one method is in the parent class, another is in the child class.
12) What do you mean by an abstract in Java?
Abstract classes in Java means that the classes cannot be instantiated and can only be used to extend another class. Similarly, abstract methods in Java have nobody and are only used for overridden by the existing extended class.
13) Difference between array and array list in Java?
Array | Array List |
The size of the array must be specified at the time of the declaration. Array[] name = new Array[10] | The size can be allocated dynamically. ArrayList name = new ArrayList |
The index of the array must be specified to insert any object into the array. | In Array List, there is no need of index specifications. |
The Array is not type parameterized. | The Array list is type parameterised |
15) What is the difference between HashMap and HashTable?
HashMap | HashTable |
No synchronization of methods | Key methods are synchronization |
Iterator is used to iterate the values | The Enumerator is used to iterate the values |
One null key and multiple null values are allowed | Nothing with null attribute is allowed |
There is no thread safety | Thread safety |
Higher performance | Slower performance |
Conclusion:
These were some of the most frequently Java Interview Questions. Note that all of these questions have been answered by our Java experts which will help you enrich your knowledge in terms of Java programming and excel at the interview.
To gain more insight into Java concepts, you can also see Technical Interview Questions.
I hope my blog helps you ace your interview!
Wish you all the best!
Share:
Comments
Waiting for your comments