- 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 3
![]() Share with a Friend |
Multiple Choice Questions
Java - Introduction to Java - Multiple Choice Questions (MCQ) - Set 3
11. Which keyword is used to define class?A). define
B). class
C). struct
D). object
View Answer
Explanation
The correct keyword used to define a class is B). class.
In major object-oriented programming languages, this keyword serves as the standard for declaring a class:
- Java:The class keyword is essential for creating every line of code, as all Java code must exist within a class.
- Python:It is used to create a blueprint for objects, bundling data and functionality together.
- C++:It defines a user-defined data type that holds data members and member functions.
- C#: A class declaration must begin with the classkeyword followed by the identifier.
Why the other options are incorrect:
A). define: Primarily used in languages like C/C++ to create macros or in Python (as def) to define functions.
C). struct:Used in C to define structures and in C++ as an alternative for declaring classes with default public access.
D). object:This is an instance created from a class, not a keyword for defining the class itself.
12. Entry point of Java program:
A). start()
B). main()
C). run()
D). init()
Explanation
The correct answer is B). main().
In Java, the main() method is the standard entry point where the Java Virtual Machine (JVM) begins executing a standalone application.
Key Characteristics of the Entry Point:
- Required Signature: For the JVM to recognize it as the starting point, it must be defined exactly as public static void main(String[] args).
- Execution: When a program is launched via the java command, the JVM loads the specified class and invokes its main()
- Purpose of Keywords:
- public: Allows the JVM to access the method from outside the class.
- static: Enables the JVM to call the method without first creating an instance (object) of the class.
- void: Indicates that the method does not return any value to the JVM after finishing execution.
Comparison of Other Options:
- start(): Used to begin the execution of a thread or to start an applet.
- run(): The entry point for logic within a separate Thread or Runnable task.
- init(): Historically used as the first method called when initializing a Java Applet.
13. Java is compiled into:
A). Machine code
B). Bytecode
C). Assembly
D). Binary
View Answer
Explanation
The correct answer is : B). Bytecode
- Java Bytecode: When you run the Java compiler (javac), it translates your human-readable source code into an intermediate, platform-independent format called Java Bytecode.
- Class Files: This bytecode is saved on the disk with a .class
- Role of the JVM: The Java Virtual Machine (JVM)then loads these class files and executes the bytecode by either interpreting it or using a Just-In-Time (JIT) compiler to convert it into native machine code specific to the host operating system.
- Platform Independence: This two-step process allows Java to follow the "Write Once, Run Anywhere" (WORA) principle, as the same bytecode can run on any system that has a compatible JVM installed.
14. Which is not a Java feature?
A). Platform independent
B). Secure
C). Pointer-based
D). Robust
Explanation
The correct answer is C). Pointer-based.
The following are established features of Java:
- Platform independent: Java code is compiled into bytecode that can run on any system with a Java Virtual Machine (JVM).
- Secure: Java provides a secure environment by using a bytecode verifierand avoiding explicit pointers that could allow unauthorized memory access.
- Robust: Java emphasizes reliability through strong memory management, automatic garbage collection, and comprehensive exception handling.
- Pointer-basedis not a feature because Java deliberately omits traditional pointer support (such as pointer arithmetic) found in languages like C and C++ to ensure safety and simplicity.
15. Java uses which memory management?
A). Manual
B). Automatic
C). Semi-manual
D). None
View Answer
Explanation
Java uses Automatic memory management.
B). Automatic
Key Details:
- Java utilizes an automatic memory management system known as Garbage Collection (GC).
- The Java Virtual Machine (JVM) automatically allocates memory for new objects and deallocates memory when objects are no longer in use, which removes the need for manual memory management (like in C or C++).
- Garbage collector runs periodically to identify unreferenced objects and reclaim their memory.
