Below is a comprehensive list of the most important and commonly asked basic and advanced Java programming interview questions with detailed answers.
1) What is Java?
Answer: Java is a high-level programming language and is platform-independent.
Java is a collection of objects. It was developed by Sun Microsystems. A lot of applications, websites and games have been developed using Java.
2) What are the features in Java?
Answer: The features of Java are as follows:
OOPs concepts
object oriented
Inheritance
encapsulation
Polymorphism
Abstraction
Platform independent: A single program works on various platforms without any modification.
High Performance: JIT (Just in Time Compiler) enables high performance in Java. JIT converts the bytecode into machine language and then starts JVM execution.
Multi-threaded: The flow of execution is known as thread. The JVM creates a thread called the main thread. The user can create multiple threads by expanding the thread class or implementing a runnable interface.
3) How does Java enable high performance?
Answer: Java uses the Just in Time compiler to enable high performance. It is used to convert instructions to bytecodes.
4) Name the Java IDE?
Answer: Eclipse and Netbeans are Java's IDEs.
5) What does constructor mean?
Answer: The constructor is explained in detail:
When a new object is created in a program, a constructor is assigned to the class.
The constructor is a method that has the same name as the class name.
If a user does not create a constructor, then obviously a default constructor will be created.
Constructors can be overloaded.
If the user has created a constructor with one parameter, then it must explicitly create another constructor with no parameters.
6) What do local variables and instance variables mean?
answer: Local variables are defined in the method and scope of the variables present inside the method.
Instance variables are defined inside the class and outside the method, and the scope of the variables is present throughout the class.
7) What is class?
Answer: All Java code is defined in a class. It has variables and methods.
Variables are the attributes that define the state of a class.
Methods are the place where precise business reasoning has to be done. It consists of a set of descriptions (or) instructions to fulfill a particular requirement.
Examples:
Public class add {// class name declaration
int a = 5; // variable declaration
int b = 5;
Public void add () {// method declaration
int c = a + b;
}
}
8) What is an object?
Answer: An example of a class is called an object. The object has state and behavior.
Whenever JVM reads "new ()" keyword it will create an instance of that class.
Examples:
Public class addition {
public static void main (String [] args){
AddAdd = add new (); // object creation
}
}
The above code creates an object for the Addition class.
9) What are OOPs concepts?
Answer: OOPs concepts include:
Inheritance
encapsulation
Polymorphism
Abstraction
The interface
10) What is inheritance?
Answer: Inheritance means that one class can expand to another class. So that the codes can be reused from one class to another. The existing class is known as the super class while the derived class is known as the sub class.
Examples:
Super Class:
Public class interrupt () {
}
Subclass:
Public class Manipulate () {
}
Inheritance only applies to public and protected members. Private members cannot be inherited.
1) What is Java?
Answer: Java is a high-level programming language and is platform-independent.
Java is a collection of objects. It was developed by Sun Microsystems. A lot of applications, websites and games have been developed using Java.
2) What are the features in Java?
Answer: The features of Java are as follows:
OOPs concepts
object oriented
Inheritance
encapsulation
Polymorphism
Abstraction
Platform independent: A single program works on various platforms without any modification.
High Performance: JIT (Just in Time Compiler) enables high performance in Java. JIT converts the bytecode into machine language and then starts JVM execution.
Multi-threaded: The flow of execution is known as thread. The JVM creates a thread called the main thread. The user can create multiple threads by expanding the thread class or implementing a runnable interface.
3) How does Java enable high performance?
Answer: Java uses the Just in Time compiler to enable high performance. It is used to convert instructions to bytecodes.
4) Name the Java IDE?
Answer: Eclipse and Netbeans are Java's IDEs.
5) What does constructor mean?
Answer: The constructor is explained in detail:
When a new object is created in a program, a constructor is assigned to the class.
The constructor is a method that has the same name as the class name.
If a user does not create a constructor, then obviously a default constructor will be created.
Constructors can be overloaded.
If the user has created a constructor with one parameter, then it must explicitly create another constructor with no parameters.
6) What do local variables and instance variables mean?
answer: Local variables are defined in the method and scope of the variables present inside the method.
Instance variables are defined inside the class and outside the method, and the scope of the variables is present throughout the class.
7) What is class?
Answer: All Java code is defined in a class. It has variables and methods.
Variables are the attributes that define the state of a class.
Methods are the place where precise business reasoning has to be done. It consists of a set of descriptions (or) instructions to fulfill a particular requirement.
Examples:
Public class add {// class name declaration
int a = 5; // variable declaration
int b = 5;
Public void add () {// method declaration
int c = a + b;
}
}
8) What is an object?
Answer: An example of a class is called an object. The object has state and behavior.
Whenever JVM reads "new ()" keyword it will create an instance of that class.
Examples:
Public class addition {
public static void main (String [] args){
AddAdd = add new (); // object creation
}
}
The above code creates an object for the Addition class.
9) What are OOPs concepts?
Answer: OOPs concepts include:
Inheritance
encapsulation
Polymorphism
Abstraction
The interface
10) What is inheritance?
Answer: Inheritance means that one class can expand to another class. So that the codes can be reused from one class to another. The existing class is known as the super class while the derived class is known as the sub class.
Examples:
Super Class:
Public class interrupt () {
}
Subclass:
Public class Manipulate () {
}
Inheritance only applies to public and protected members. Private members cannot be inherited.
This problem set is very high-level and contains great set of questions. Amazing. Find an another great set of questions on data structures and algorithms, at Logic Mojo.
ReplyDeleteKeep sharing these questions. I would add preparing data structures and algorithms in Java, for overall understanding of core concepts of programming.
ReplyDeletePost a Comment