Programming with Java: Chapterwise Mock Test with Explanations
Chapter 1: Fundamentals of Object-Oriented Programming
1. Which of the following is not a feature of object-oriented programming?
A. Encapsulation
B. Inheritance
C. Procedural abstraction
D. Polymorphism
Answer: C
Explanation: Procedural abstraction is a feature of procedural programming. OOP emphasizes
encapsulation, inheritance, and polymorphism.
2. Which of the following best describes encapsulation?
A. Deriving a new class from an existing class
B. Binding data and methods together
C. Using one name for multiple methods
D. Hiding the implementation details
Answer: B
Explanation: Encapsulation binds data and the code that manipulates it. It hides internal details and
exposes only required interfaces.
3. What is the term for the ability of different objects to respond in a unique way to the same
message?
A. Inheritance
B. Encapsulation
C. Abstraction
D. Polymorphism
Answer: D
Explanation: Polymorphism allows the same operation to behave differently on different classes.
4. What is the main advantage of object-oriented programming over procedural programming?
A. Easier to write code
B. Higher execution speed
C. Better code modularity and reuse
D. Lower memory consumption
Answer: C
Explanation: OOP encourages modular, reusable code by organizing it around objects and classes.
5. Which of the following languages is not object-oriented?
A. C++
B. Java
C. Python
D. C
Answer: D
Explanation: C is a procedural language. It does not support object-oriented features like classes
and objects natively.
Chapter 2: Java Evolution
1. Java was developed by:
A. Microsoft
B. Sun Microsystems
C. Apple
D. IBM
Answer: B
Explanation: Java was developed by Sun Microsystems in the early 1990s and later acquired by
Oracle.
2. What was the original name of Java?
A. Oak
B. Pine
C. Maple
D. Cedar
Answer: A
Explanation: The original name of Java was Oak, which was later changed to Java due to trademark
issues.
3. Which of the following is not a feature of Java?
A. Platform Independence
B. Pointer Arithmetic
C. Object-Oriented
D. Robustness
Answer: B
Explanation: Java does not support pointer arithmetic for security and simplicity.
4. Which year was Java officially released?
A. 1991
B. 1995
C. 2000
D. 1998
Answer: B
Explanation: Java was officially released in 1995 by Sun Microsystems.
5. What does JVM stand for?
A. Java Virtual Machine
B. Java Variable Manager
C. Java Visual Module
D. Java Verified Memory
Answer: A
Explanation: JVM stands for Java Virtual Machine which allows Java programs to run on any device
or OS.