Most frequently asking java basics interview questions and answers has been updated in the post. 
Q1: How many JVM's can run on a single machine?

No limitation. JVM is just like any other process.

What is the Just-In-Time (JIT) compiler?

The java interpreter on any platform will interpret the compiled bytecode into instructions understandable by the particular hardware. However, the Java Virtual Machine handles one bytecode instruction at a time. The Just-In-Time compiler compiles the bytecode into the particular machine code. Once the code has been (re-)compiled by the JIT compiler, it will usually run more quickly in that system.
JIT Compiler is the part of JVM which increases the speed of execution of a java program.

What is the use of 'classpath' environment variable?

Classpath is the list of directories through which the jvm will search to find a class. It is different from OS environment variable PATH.

If you need to learn how to set classpath, please go through this link set Java Path?

 Can java code be retrieved from byte-code?

Yes, class files can be de-compiled using utilities like JAD. This takes the class file as input and generates a java file.

What is a garbage collection?

When an object is no longer required (when its reference count is 0), its memory needs to be cleaned up and freed. This is what the garbage collector does. Garbage collector is a thread running as part of the JVM process. The basic garbage collector uses "mark and sweep" algorithm.

Can the garbage collector be forced to run?

A: No. Calling the System.gc() method only suggest that the JVM expand effort toward recycling unused objects in order to make the memory they currently occupy available for them. When control returns from the method call, the JVM has made a best effort to reclaim space from all declared objects. This doesn't guarantee that the garbage collector is called

The call System.gc() is effectively equivalent to the call:


Garbage Collector is automatically invoked when the program is being run. It can be also called by calling gc() method of Runtime class or System class in java.
  • Java Basics


Google Interview Questions:
  • What is promising and Hoisting in JavaScript?
  • How will you make async call from JavaScript?
  • What is box model in CSS?
  • What is the major differences between ArrayList and LinkedList?
  • How will you prove LinkedList is better than ArrayList to store elements in the middle?
  • What are the differences between HashMap, TreeMap and LinkedHashMap?
  • Write a method to get an element from given array by using BinarySearch?
    • int[] ar = {4,1,3,10,-4,-2};
  • What are the different approaches of Sorting the above Array?
  • What are the different types of design patterns you worked?
  • What is the best way of implementing Singleton design pattern?
  • What is the difference between Factory and Abstract Factory pattern?
  • How will you implement Builder patter?

Popular posts from this blog

JNDI configuration for Tomcat 9 with Oracle

Multithreading in java with example

Prime, Fibonacci and Factorial number with example in java