Category Archives: Java JVM Interview Questions

What is the Java Virtual Machine (JVM)? | Java JVM Questions

The Java Virtual Machine is software that can be ported onto various hardware-based platforms.

Posted in Java JVM Interview Questions | Leave a comment

What is the difference between the boolean & operator and the && operator? | Java JVM Questions

If an expression involving the boolean & operator is evaluated, both operands are evaluated, whereas the && operator is a short cut operator. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first … Continue reading

Posted in Java JVM Interview Questions | Leave a comment

What is the difference between declaring a variable and defining a variable? | Java JVM Questions

In declaration we only mention the type of the variable and its name without initializing it. Defining means declaration + initialization. E.g. String s; is just a declaration while String s = new String (”bob”); Or String s = “bob”; … Continue reading

Posted in Java JVM Interview Questions | Leave a comment

What type of parameter passing does Java support? | Java JVM Questions

In Java the arguments (primitives and objects) are always passed by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object.

Posted in Java JVM Interview Questions | Leave a comment

What do you understand by a variable? | Java JVM Questions

Variable is a named memory location that can be easily referred in the program. The variable is used to hold the data and it can be changed during the course of the execution of the program.

Posted in Java JVM Interview Questions | Leave a comment

What do you understand by casting in java language? What are the types of casting? | Java JVM Questions

The process of converting one data type to another is called Casting. There are two types of casting in Java; these are implicit casting and explicit casting.

Posted in Java JVM Interview Questions | Leave a comment

What is the first argument of the String array in main method? | Java JVM Questions

The String array is empty. It does not have any element. This is unlike C/C++ where the first element by default is the program name. If we do not provide any arguments on the command line, then the String array … Continue reading

Posted in Java JVM Interview Questions | Leave a comment

How can one prove that the array is not null but empty? | Java JVM Questions

Print array.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print array.length.

Posted in Java JVM Interview Questions | Leave a comment

Can an application have multiple classes having main method? | Java JVM Questions

Yes. While starting the application we mention the class name to be run. The JVM will look for the main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having … Continue reading

Posted in Java JVM Interview Questions | Leave a comment

When is static variable loaded? Is it at compile time or runtime? When exactly a static block is loaded in Java? | Java JVM Questions

Static variable are loaded when classloader brings the class to the JVM. It is not necessary that an object has to be created. Static variables will be allocated memory space when they have been loaded. The code in a static … Continue reading

Posted in Java JVM Interview Questions | Leave a comment