JAVA
Interview Questions
for freshers
Learn more
Q1. What is Java?
Q1. What is Java?
Java is a high-level, object-oriented programming language and its platform-independent, allowing it to run on any platform.
Java is a high-level, object-oriented programming language and its platform-independent, allowing it to run on any platform.
It is widely used for developing desktop, mobile, enterprise-level, and web applications.
It is widely used for developing desktop, mobile, enterprise-level, and web applications.
Q2. What is a class in
Java?
Q2. What is a class in
Java?
A class is a blueprint for creating objects in Java.
A class is a blueprint for creating objects in Java.
It defines the properties and behaviours that an object will possess.
It defines the properties and behaviours that an object will possess.
Q3. Why is Java a platform independent language?
Q3. Why is Java a platform independent language?
Java is platform independent because it converts code to byte code.
Java is platform independent because it converts code to byte code.
Byte code is platform-independent and can run on multiple systems.
Byte code is platform-independent and can run on multiple systems.
Q4. Which class is a superclass of all classes?
Q4.
Which class is a superclass of all classes?
The root class for all Java classes is java.lang. Object.
The root class for all Java classes is java.lang. Object.
All non-primitive types and arrays are inherited from this class, either directly or indirectly.
All non-primitive types and arrays are inherited from this class, either directly or indirectly.
Q5.
What are instance and local variables?
Q5.
What are instance and local variables?
Instance variables are accessible by all class methods, while local variables are restricted to a block, function, or constructor.
Instance variables are accessible by all class methods, while local variables are restricted to a block, function, or constructor.
Instance variables describe an object's properties and remain bound to it, while local variables have limited scope within a block or method.
Instance variables describe an object's properties and remain bound to it, while local variables have limited scope within a block or method.
Q6. What are Java's access specifiers?
Q6.
What are Java's access specifiers?
Public
Public
Protected
Protected
Private
Private
Default
Default
Q7. How many types of constructors are used in Java?
Q7.
How many types of constructors are used in Java?
Default Constructor
Default Constructor
Parameterized Constructor
Parameterized Constructor
Q8. Name the Memory Allocations available in Java
Q8. Name
the Memory Allocations available in Java
Class Memory
Class Memory
Heap Memory
Heap Memory
Stack Memory
Stack Memory
Program Counter-Memory
Program Counter-Memory
Native Method Stack Memory
Native Method Stack Memory
Q9. What is a package in Java?
Q9.
What is a package in Java?
Java packages group related classes, like folders in a file directory.
Java packages group related classes, like folders in a file directory.
Packages help avoid naming conflicts and improve code maintainability.
Packages help avoid naming conflicts and improve code maintainability.
Q10. Difference between a constructor and a method in Java?
Q10. D
ifference between a constructor and a method in Java?
Constructor: Used to create and initialize an object of a class.
Constructor: Used to create and initialize an object of a class.
Method: A block of code that can be called multiple times within a class.
Method: A block of code that can be called multiple times within a class.
Preparing to attend interview for Java?
Learn with Whizlabs!
Explore