Here are the Core Java Interview Questions that can be asked to you by interviewers. These frequently asked Core Java Interview Questions will be beneficial to software developers going for Java developer Interviews.
Q 1. Difference between JDK, JRE and JVM?
JVM stands for Java Virtual Machine that provides runtime environment in which java bytecode can be executed. JVM is platform dependent and is responsible for garbage collection, array bounds and checking. JVM is independent from hardware and operating system.
JRE stands for Java Runtime Environment, which comprises of JVM and class libraries. However compiler and debugger are not included in it. JRE is a must in system if one wants to run a Java file.
JRE executes Java files.
JDK stands for Java Development Kit that has both developer tools like compiler, Java application launcher Appletviewer and JRE to run the programs.
JDK is required for programmers who write their own programs
Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.
JDK is for java development.
Q 2. What is an interface in java?
Interface in Java is the collection of methods with empty implementations and constants variables. Methods in an Interface are public and abstract. Implement keyword is used to define methods.
Q 3. What is the Purpose of finalization?
Finalization() method cleans up memory of an object before Garbage Collector cleans it. It is an arbitrary method that contains arbitrary code.
Q 4. What is the garbage collection in Java?
Garbage collection is provided by JVM (Java Virtual Machine) to clean the heap space from objects. Garbage collection is carried out by Garbage collector. Garbage collection is invoked automatically by JVM.
Q 5. Difference between abstract class and interface in java?
- Method and members of an abstract class can be defined as private, protected, etc while methods of an interface are public by default.
- Sub-class of an abstract class must define abstract methods while Interface can be extended to another interface without defining the method.
- Interface is a form of multiple inheritance while an abstract class can be extended to one other class.
Q 6. What is Jagged Arrays in java?
Jagged Array in Java is a new feature. It is an array of arrays. It is used when you have a non-uniform array as you can serialize a data to save it.