MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPUTER ORGANIZATION

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Why is it necessary for programs compiled to bytecode (like Java) to use a virtual machine?
A
The programs are all the same, but the machines they run on are different and the virtual machine acts as the interpreter.
B
The virtual machine needs to be the same on each machine in order to run the bytecode.
C
Compiling to bytecode means that it will run more efficiently on each system.
D
None of the above
Explanation: 

Detailed explanation-1: -What is bytecode and why is it important to Java’s use for Internet programming? Bytecode is a highly optimized set of instructions that is executed by the Java Virtual Machine. Bytecode helps Java achieve both portability and security.

Detailed explanation-2: -Java Virtual Machine (or JVM) allows a computer to interpret or run Java programs. It acts as a compiler for generating machine code. All Java programs require a Runtime Environment. If you want Java apps to run at all, you’ll need a JVM (Java Virtual Machine).

Detailed explanation-3: -Answer: A Java program can be compiled once into a Java Bytecode program. The compiled program can then be run on any computer that has an interpreter for the Java virtual machine. Other languages have to be re-compiled for each platform on which they are going to run.

Detailed explanation-4: -Advantages of bytecode: Bytecode runs only when the interpreter is available. It runs on the Java virtual machine only. It gives flexibility by giving a quote ‘Write code once, run code anywhere’. It also saves a lot of time for a programmer.

There is 1 question to complete.