- Home
- Java Programming MCQ
- Introduction to Java
- Beginners
- Introduction to Java - Set 1
- Introduction to Java - Set 2
- Introduction to Java - Set 3
- Introduction to Java - Set 4
- Introduction to Java - Set 5
- Introduction to Java - Set 6
- Introduction to Java - Set 7
- Introduction to Java - Set 8
- Introduction to Java - Set 9
- Introduction to Java - Set 10
- Introduction to Java - Set 11
- Introduction to Java - Set 12
- Introduction to Java - Set 13
- Introduction to Java - Set 14
- Introduction to Java - Set 15
- Introduction to Java - Set 16
- Introduction to Java - Set 17
- Introduction to Java - Set 18
- Introduction to Java - Set 19
- Introduction to Java - Set 20
- Introduction to Java - Set 21
- Introduction to Java - Set 22
- Introduction to Java - Set 23
- Introduction to Java - Set 24
- Introduction to Java - Set 25
- Introduction to Java - Set 26
- Introduction to Java - Set 27
- Introduction to Java - Set 28
- Introduction to Java - Set 29
- Introduction to Java - Set 30
- Introduction to Java - Set 31
- Introduction to Java - Set 32
- Introduction to Java - Set 33
- Intermediate
- Introduction to Java - Set 34
- Introduction to Java - Set 35
- Introduction to Java - Set 36
- Introduction to Java - Set 37
- Introduction to Java - Set 38
- Introduction to Java - Set 39
- Introduction to Java - Set 40
- Introduction to Java - Set 41
- Introduction to Java - Set 42
- Introduction to Java - Set 43
- Introduction to Java - Set 44
- Introduction to Java - Set 45
- Advanced Level
- Introduction to Java - Set 46
- Introduction to Java - Set 47
- Introduction to Java - Set 48
- Introduction to Java - Set 49
- Introduction to Java - Set 50
- Introduction to Java - Set 51
- Introduction to Java - Set 52
- Introduction to Java - Set 53
- Introduction to Java - Set 54
- Introduction to Java - Set 55
- Data Types & Variables
- Operators in Java
- Control Statements
- Arrays
- Strings
- Object-Oriented Programming (OOP)
- Interfaces & Abstract Classes
- Exception Handling
- Multithreading
- Collections Framework
- File Handling
- JDBC (Database Connectivity)
- Java MCQ - Loops, Decisions and Mathematical functions
- Loops, Decisions and Mathematical functions MCQ
- Loops, Decisions and Mathematical functions MCQ - Set 1
- Loops, Decisions and Mathematical functions MCQ - Set 2
- Loops, Decisions and Mathematical functions MCQ - Set 3
- Loops, Decisions and Mathematical functions MCQ - Set 4
- Loops, Decisions and Mathematical functions MCQ - Set 5
- Loops, Decisions and Mathematical functions MCQ - Set 6
- Loops, Decisions and Mathematical functions MCQ - Set 7
- Loops, Decisions and Mathematical functions MCQ - Set 8
- Java MCQ - Methods and Arrays
- Methods and Arrays MCQ
- Methods and Arrays MCQ - Set 1
- Methods and Arrays MCQ - Set 2
- Methods and Arrays MCQ - Set 3
- Methods and Arrays MCQ - Set 4
- Methods and Arrays MCQ - Set 5
- Methods and Arrays MCQ - Set 6
- Methods and Arrays MCQ - Set 7
- Methods and Arrays MCQ - Set 8
- Methods and Arrays MCQ - Set 9
- Java MCQ - Objects and Classes
- Objects and Classes MCQ
- Objects and Classes MCQ - Set 1
- Objects and Classes MCQ - Set 2
- Objects and Classes MCQ - Set 3
- Objects and Classes MCQ - Set 4
- Objects and Classes MCQ - Set 5
- Objects and Classes MCQ - Set 6
- Objects and Classes MCQ - Set 7
- Java MCQ - Objects Oriented Programming
- Java MCQ - Exception Handling, I/O, Abstract classes and Interfaces
- Java MCQ - JAVAFX basics and Event-driven programming and animations
- Java MCQ - JAVAFX UI controls and multimedia
- Java MCQ - Binary I/O ,Recursion and Generics
- Java MCQ - List, Stacks, Queues and Priority Queues
- Java MCQ - Sets and Maps
- Java MCQ - Concurrency
============================================================================
Java Programming Multiple Choice Questions (MCQ)
Introduction to Java - Multiple Choice Questions (MCQ) - Set 4
![]() Share with a Friend |
Multiple Choice Questions
Java - Introduction to Java - Multiple Choice Questions (MCQ) - Set 4
16. JVM is part of:A). JDK
B). JRE
C). Both
D). None
View Answer
Explanation
The correct answer is C). Both.
- JVM (Java Virtual Machine)is the core engine that executes Java bytecode.
- JRE (Java Runtime Environment)is a package that includes the JVM and class libraries, allowing Java applications to run.
- JDK (Java Development Kit)is a full-featured software development kit that includes the JRE (and thus the JVM), along with tools like the compiler (javac) and debuggers.
Therefore, the JVM is a component within the JRE, and because the JRE is included in the JDK, the JVM is part of both.
Hierarchical View:
JDK > JRE > JVM
17. Which tool compiles Java code?
A). javac
B). java
C). jvm
D). jre
Explanation
The tool that compiles Java code is A). javac.
Summary of Java Tools:
A. javac (Java Compiler):The primary tool used to read Java source files (.java) and compile them into platform-independent bytecode (.class files).
B. java (Java Launcher):The tool used to launch and run Java applications by starting a Java Virtual Machine.
C. JVM (Java Virtual Machine):The abstract engine that executes Java bytecode on a specific hardware platform.
D. JRE (Java Runtime Environment):A software bundle that provides the libraries and JVM needed to run Java programs, but does not include development tools like a compiler.
18. Which command runs Java program?
A). javac
B). java
C). run
D). compile
View Answer
Explanation
The correct command to run a Java program is B). java.
In the Java development process, there are two distinct steps involving different commands:
- Compilation:The javac command (Java Compiler) is used to translate source code (.java files) into bytecode (.class files).
- Execution:The java command (Java Launcher) starts the Java Virtual Machine (JVM), loads the compiled .class file, and runs the program.
Example of the process:
- Compile:javac HelloWorld.java (creates class).
- Run:java HelloWorld (executes the program)
19. Java supports multithreading?
A). Yes
B). No
Explanation
A). Yes
Java supports multithreading natively, allowing a program to run multiple threads simultaneously to execute tasks in parallel and utilize CPU resources more efficiently. This support is built into the language through the Thread class and the Runnable interface, allowing developers to create independent paths of execution that share the same memory space.
Key Aspects of Multithreading in Java:
- Built-in Support:Java provides built-in mechanisms for creating, managing, and synchronizing threads, such as synchronized blocks, wait(), and notify().
- Two Primary Ways to Create Threads:Extending the Thread class or implementing the Runnable
- Concurrency Utilities:The util.concurrent package provides advanced tools like ExecutorService for managing thread pools, which are preferred for creating scalable applications.
- Parallelism:On multi-core processors, Java threads can run in true parallel, improving application performance.
20. Which is not part of JDK?
A). Compiler
B). JVM
C). JRE
D). Browser
View Answer
Explanation
The correct answer is D). Browser.
Here is the breakdown of why:
- JDK (Java Development Kit) is a comprehensive software development kit used for creating Java applications.
- JDK includes JRE (C), which in turn includes the JVM (B).
- Compiler (A), specifically javac, is a key tool included in the JDK to turn source code into bytecode.
- Browser (D) is not part of the JDK. While browsers used to run Java applets using a browser plugin, that plugin was separate from the JDK and has been deprecated/removed in modern versions.
