Posts

PBCST 304 Object Oriented Programming Model Question Paper and Answers

  1.You compile MyApp.java on Windows into MyApp.class, then copy that same MyApp.class file to both a Linux machine and a macOS system. Without recompiling, you run: java MyApp on each machine, and it executes successfully. What is the name of the compiled file format that makes this possible? When you compile a Java source file ( MyApp.java ) using the Java compiler ( javac ), it does not produce machine code specific to Windows, Linux, or macOS. Instead, it produces platform-independent bytecode , which is stored in the file: MyApp. class This file contains instructions for the Java Virtual Machine (JVM) , not for any specific hardware or operating system  Why it runs everywhere Each platform (Windows, Linux, macOS) has its own JVM implementation . When you run: java MyApp The JVM on that platform reads and executes the same bytecode instructions — making Java platform-independent . 2.What will be the value of a after the execution of the following code  ...