MCQ on JVM and Java Memory management

Q) What is output of this java program?
public class MemoryJava {

	public static void main(String[] args) {
	public static void decreaseNumberbyOne(int num){
		if(num >= 0){
			decreaseNumberbyOne(num -1);


  1. -1,0,1,2
  2. 2,1,0,-1
  3. Stack overflow
  4. No output

Answer: 1: -1,0,1,2

Q) Byte code is
  1. Machine-dependent
  2. Machine-instruction
  3. Machine- independent
  4. None of these

Answer: 3
Byte code is machine independent. This the reason we say that java is platform independent language.
Compiler converts program to byte code (class file) and since this byte code is platform independent, it can be placed on any machine and by JVM program can be run.

Q) On successful compilation of a java source code _____________ is generated
  1. Output
  2. Bytecode
  3. Octal code
  4. Hexadecimal code

Answer: 2

Q) Java compiled source code programs have extension
  1. .java
  2. . source
  3. .class
  4. . compile

Answer: 3
After successful compilation of java source code program compiler convert it into a byte code i.e. a class file with extension .class

Related Posts