Q) What is output of this java program?
public class MemoryJava {
public static void main(String[] args) {
decreaseNumberbyOne(2);
}
public static void decreaseNumberbyOne(int num){
if(num >= 0){
decreaseNumberbyOne(num -1);
}
System.out.println("Number:"+num);
}
}
- -1,0,1,2
- 2,1,0,-1
- Stack overflow
- No output
Answer: 1: -1,0,1,2
Q) Byte code is
- Machine-dependent
- Machine-instruction
- Machine- independent
- 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
- Output
- Bytecode
- Octal code
- Hexadecimal code
Answer: 2
Q) Java compiled source code programs have extension
- .java
- . source
- .class
- . 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