- 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 1
![]() Share with a Friend |
Multiple Choice Questions
Java - Introduction to Java - Multiple Choice Questions (MCQ) - Set 1
1. What does JVM stand for?A). Java Variable Machine
B). Java Virtual Machine
C). Java Verified Machine
D). Java Visual Machine
View Answer
Explanation
The correct answer is B). Java Virtual Machine.
The Java Virtual Machine (JVM) is an abstract computing machine that provides a runtime environment for executing Java bytecode. It is the core component that enables Java's "Write Once, Run Anywhere" (WORA) capability by translating platform-independent bytecode into machine-specific instructions for the host operating system.
2. Java is a ______ language.
A). Procedural
B). Machine-level
C). Object-Oriented
D). Assembly
Explanation
The correct option is ✅ C. Object-Oriented.
Explanation
Java is fundamentally an Object-Oriented programming language because it is built around the concept of "objects" that contain both data (attributes) and code (methods). It was specifically designed to be "simple, object-oriented, and familiar" by its creator, James Gosling. While Java is sometimes not considered "purely" object-oriented because it supports primitive data types (like int and char) and static members, its core architecture relies on the four pillars of object-oriented programming: Encapsulation, Inheritance, Abstraction, and Polymorphism.
Why other options are incorrect
- ❌ Procedural: While Java can support procedural styles through static methods, it is primarily class-based. Procedural languages, like C, emphasize functions and a sequence of commands rather than objects.
- ❌ Machine-level: This is a low-level language consisting of binary (0s and 1s) that the CPU understands directly. Java is a high-level language that must be compiled into bytecode and then interpreted by the Java Virtual Machine (JVM).
- ❌ Assembly: Assembly is a low-level language that uses mnemonics to interact directly with computer hardware. Java operates at a much higher level of abstraction and is platform-independent.
3. Which component compiles Java code?
A). JVM
B). JRE
C). JDK
D). JIT
View Answer
Explanation
The correct component that compiles Java code is C). JDK.
In the Java ecosystem, compilation occurs in two primary stages involving different components:
- JDK (Java Development Kit) : This is the full development environment that includes the Java compiler (javac). It is responsible for converting human-readable Java source code (.java files) into platform-independent bytecode (.class files).
- JIT (Just-In-Time Compiler) : While JIT is technically a compiler, it operates at runtime within the JVM. It translates frequently used bytecode into native machine code to optimize performance.
Comparison of Options:
- JDK : Contains development tools like javac used to compile source code.
- JRE (Java Runtime Environment) : Provides the minimum requirements to run Java applications but does not include the compiler.
- JVM (Java Virtual Machine) : The engine that executes the compiled bytecode on a specific platform.
- JIT : An optimization component of the JVM that compiles bytecode to machine code during execution.
4. Java source files have extension:
A). .class
B). .java
C). .exe
D). .js
Explanation
The correct answer is B). .java.
In Java programming, different file extensions serve specific purposes during the development and execution lifecycle:
- .java (Source Files) : This extension is used for plain text files containing human-readable Java source code. These files are the starting point for developing any Java application.
- .class (Compiled Files) : This extension represents Java Class Files. These are generated by the Java compiler (javac) and contain platform-independent bytecode that the Java Virtual Machine (JVM) can execute.
- .exe (Executables) : This extension is typically used for Windows executable files and is not a native Java source or bytecode extension.
- .js (JavaScript Files) : This extension is reserved for JavaScript, a scripting language used primarily for web browsers, and is unrelated to Java source programs.
5. Java bytecode is executed by:
A). Compiler
B). JVM
C). OS
D). Editor
View Answer
Explanation
Java bytecode is executed by the JVM (Java Virtual Machine).
- JVM (Java Virtual Machine):The JVM is the core component that reads and executes Java bytecode, acting as an interpreter and a Just-In-Time (JIT) compiler to run the code on the underlying operating system.
- Platform Independence:This process enables Java's "Write Once, Run Anywhere" capability, as the same bytecode can be executed on any machine that has a JVM installed.
- Process:The Java compiler (javac) converts .java source files into .class bytecode files, which are then executed by the JVM.
Therefore, the correct option is B). JVM.
