InterviewTop 10 question for Java interview

Top 10 question for Java interview

What is the difference between JDK and JRE?

JDK is the Java Programming Kit. It includes Java software creation tools and libraries. It also includes the compilers and debuggers required to compile the Java application,
JRE is Java Runtime Environment. This is part of JDK. JRE includes the libraries and JVM required to run the Java application.

What is Java Virtual Machine (JVM)?

Java Virtual Machine (JVM) is an abstract machine that runs Java Bytecode. There are various JVMs for different hardware and device platforms. So JVM depends on the platform. JVM is responsible for loading, testing and executing the Bytecode on the platform.

Top 10 question for Java interview

What are the different types of memory areas allocated by JVM?

In Java, JVM allocates memory to various procedures, methods, and methods.
Objects,the memory areas assigned to JVM are:

  • ClassLoader: is a JVM component used to load class files.
  • Class (Function) Area: stores per class structures such as runtime constant pool, field and method data, and method code.
  • Heap: Heap generates a runtime that includes the runtime storage field in which the objects are assigned.
  • Block: Stack holds local variables and partial outputs at runtime. It also assists in the process of invocation and return value. At the time of thread formation, each thread generates a private JVM stack.
  • Software Counter Register: This memory field holds the Java virtual machine instruction address that is being run at the moment.
  • Native Method Stack: This field is reserved for all of the native methods used in the program.
Top 10 question for Java interview

Thanks for reading the Top 10 question for Java interview if you have any feedback than let us know in below comment section

What is JIT compiler?

Often known as the JIT compiler, the Just In Time compiler is used in Java for performance enhancement. By default, it is allowed. It is a very earlier compilation achieved at execution time. Java also popularized the use of the JIT compiler by including it within the JVM.

How Java platform is different from other platforms?

Windows helps you to write Java code and compile it on the Windows platform. As it is in the Unix environment, the class and jar files that you get from the Windows platform will run. So it’s a completely autonomous language of the platform.
The Java byte code is behind all this portability. Java compiler-generated byte code can be interpreted by any JVM. So writing programs in Java and expecting them to run on any platform is much simpler.

How does ClassLoader work in Java?

ClassLoader is a class of Java that is used to load files in JVM. ClassLoader loads files from their physical file location.
e.g. Filesystem, location of the network, etc.

There are three major forms of Java ClassLoader.

  1. Bootstrap ClassLoader: this is the first ClassLoader to be included. It loads classes from a file in rt.jar.
  2. Extension ClassLoader: loads class files from jre/lib/ext site.
  3. ClassLoader Application: This ClassLoader relies on CLASSPATH to find the address of the class files. If you specify your jars in CLASSPATH, this ClassLoader will load the jars.

Do you think ‘main’ used for main method is a keyword in Java?

No, main is the name of the method. There may be several methods with the same key name in a class file. It’s not a Java keyword.

Can we write main method as public void static instead of public static void?

No, you can’t type that way. Any method must first define a shift and then a return value. The order of the modifiers can be changed.
We may write a public static void main() instead of a public static void main ().

In Java, if we do not specify any value for local variables, then what will be the default value of the local variables?

Java does not load local variables with a default value. So these variables will be empty by nature.


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe Today


Get unlimited access to our EXCLUSIVE Content and our archive of subscriber stories.

Exclusive content

Latest article

More article