Java Programming Notes for Semester
Exams
1 How bytecode is generated in Java?
Bytecode is generated in Java through the Java compiler. When a Java source file (with .java extension) is compiled using the
Compiler (javac), it translates the high-level Java code into an intermediate form called bytecode. This bytecode is stored in
files and is platform-independent. The Java Virtual Machine (JVM) then interprets or compiles this bytecode into native mach
code for execution on a specific platform.
2 What will be the output of the following code snippet?
The output of the code snippet will be:
0010120123
3 Why is main method static in Java?
The main method is static in Java to allow the JVM to call it without creating an instance of the class. Since the main method
as the entry point for a Java application, it must be accessible for execution as soon as the program starts, without requiring