- 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 2
![]() Share with a Friend |
Multiple Choice Questions
Java - Introduction to Java - Multiple Choice Questions (MCQ) - Set 2
6. Which is platform-independent?A). C
B). C++
C). Java
D). Assembly
View Answer
Explanation
The correct answer is C). Java.
Explanation:
- Java:Java is platform-independent because of its "Write Once, Run Anywhere" (WORA) The Java compiler (javac) converts source code (.java) into an intermediate form called bytecode (.class file), not machine-specific code. This bytecode can run on any device that has a Java Virtual Machine (JVM) installed, regardless of the underlying operating system (Windows, Linux, macOS).
- C and C++:These are platform-dependent languages. The compiler generates machine code specific to the operating system and CPU architecture on which it is compiled. A program compiled on Windows (.exe) will not run on Linux.
- Assembly:Assembly language is highly platform-dependent, as it is designed for a specific processor architecture.
7. JRE stands for:
A). Java Runtime Environment
B). Java Run Engine
C). Java Runtime Execution
D). Java Real Engine
Explanation
The correct answer is A). Java Runtime Environment.
Key details about the JRE include:
- Definition : It is a software layer that provides the necessary libraries, resources, and the Java Virtual Machine (JVM) to execute Java applications.
- Role : While developers use the Java Development Kit (JDK) to create and compile code, end-users typically only need the JRE to run the resulting programs.
- Components : It consists of core class libraries, deployment technologies (like Java Web Start), and the JVM execution engine.
8. Which file is generated after compilation?
A). .java
B). .exe
C). .class
D). .txt
View Answer
Explanation
The correct answer is C). .class.
After a Java source code file (which has a .java extension) is successfully compiled by the Java Compiler (javac), it generates a file with a .class extension.
Here is a breakdown of why the other options are incorrect:
- .java: This is the extension for the source code filecreated by the programmer before compilation.
- .exe: This extension is typically used for executable files on Windows (often generated after compiling C or C++ programs), but Java programs are compiled into platform-neutral bytecode instead.
- .class: This file contains the Java bytecode, which is an intermediate representation that the Java Virtual Machine (JVM)can understand and execute.
- .txt: This is a generic extension for plain text files and is not a specific product of the Java compilation process.
9. Java was developed by:
A). Microsoft
B). Apple
C). Sun Microsystems
D). Google
Explanation
Java was developed by Sun Microsystems.
The language was created by James Gosling and his team (known as the "Green Team") in the early 1990s and officially released by Sun Microsystems in 1995. While Oracle Corporation is the current developer and owner following its acquisition of Sun in 2010, the original development is attributed to Sun Microsystems.
The correct option is C). Sun Microsystems.
10. Java supports:
A). Multiple inheritance via classes
B). Single inheritance
C). No inheritance
D). Only hybrid inheritance
View Answer
Explanation
The correct answer is B). Single inheritance.
Java's support for different types of inheritance is defined by the following rules:
- Single Inheritance:Java directly supports single inheritance, where a subclass is derived from only one superclass.
- Multiple Inheritance:Java does not support multiple inheritance via classes to avoid the "diamond problem", which causes ambiguity when two parent classes have methods with the same signature. It can only be achieved through
- Hybrid Inheritance:This is a combination of two or more types of inheritance. Java does not support direct hybrid inheritance through classes, though it can be implemented by combining class inheritance with
- Multilevel and Hierarchical Inheritance:Java also supports multilevel inheritance (a chain of classes) and hierarchical inheritance (multiple subclasses from one superclass).
