Java OOP: 16 MCQs with answers

All 16 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 9 questions

Q1. What is abstraction in Java?

Beginner
A Inheriting properties from a parent class B Binding data and methods into a single unit C Creating multiple methods with the same name D Hiding implementation details and showing only functionality
Show answer & explanation

Hiding implementation details and showing only functionality

Abstraction focuses on what an object does rather than how it does it, hiding implementation details.

Q2. Which keyword is used to declare an abstract class in Java?

Beginner
A static B final C abstract D interface
Show answer & explanation

abstract

The `abstract` keyword is used to declare a class or method as abstract.

Q3. Can an abstract class have concrete (non-abstract) methods?

Beginner
A No, it can only have abstract methods B No, it can only have static methods C Yes, but only if they are private D Yes, it can have both abstract and concrete methods
Show answer & explanation

Yes, it can have both abstract and concrete methods

Abstract classes can contain both abstract methods (without body) and concrete methods (with body).

Q4. Which of the following is true about abstract methods?

Beginner
A They have no body and end with a semicolon B They can be static C They can be declared as final D They must be defined in the abstract class
Show answer & explanation

They have no body and end with a semicolon

Abstract methods are declared without a body and end with a semicolon; they must be implemented by subclasses.

Q5. What is the primary purpose of abstraction in Java?

Beginner
A To reduce complexity by hiding unnecessary details B To increase execution speed C To prevent method overriding D To allow multiple inheritance
Show answer & explanation

To reduce complexity by hiding unnecessary details

Abstraction simplifies complex systems by exposing only essential features.

Q6. Which of the following can be used to achieve abstraction in Java?

Beginner
A Only interfaces B Only abstract classes C Concrete classes D Abstract classes and interfaces
Show answer & explanation

Abstract classes and interfaces

Both abstract classes and interfaces provide abstraction in Java.

Q7. Can you instantiate an abstract class directly?

Beginner
A Yes, using a factory method B Yes, but only if it has no abstract methods C Yes, using the new keyword D No, abstract classes cannot be instantiated
Show answer & explanation

No, abstract classes cannot be instantiated

Abstract classes cannot be instantiated directly; they are meant to be subclassed.

Q8. An abstract class can be declared as final.

Beginner
A True B False
Show answer & explanation

False

An abstract class cannot be final because it must be subclassed to be used.

Q9. Abstract methods can be declared as static.

Beginner
A True B False
Show answer & explanation

False

Abstract methods cannot be static because static methods cannot be overridden.

Building up · 5 questions

Q10. What happens if a class extends an abstract class but does not implement all abstract methods?

Intermediate
A A compile-time error occurs B The unimplemented methods are ignored C The subclass must also be declared abstract D The subclass becomes concrete automatically
Show answer & explanation

The subclass must also be declared abstract

If a subclass does not implement all inherited abstract methods, it must be declared abstract itself.

Q11. Which of the following is a correct way to declare an abstract method?

Intermediate
A public abstract void display(); B public abstract void display() { } C public void abstract display(); D abstract public void display() { }
Show answer & explanation

public abstract void display();

Abstract methods are declared with the `abstract` keyword, no body, and end with a semicolon.

Q12. What is the output of the following code? abstract class A { abstract void show(); } class B extends A { void show() { System.out.println("Hello"); } } public class Main { public static void main(String[] args) { A obj = new B(); obj.show(); } }

Intermediate
A Hello B No output C Runtime error D Compilation error
Show answer & explanation

Hello

The abstract class reference `obj` points to a `B` object, and `show()` is overridden in `B`, so it prints "Hello".

Q13. Which statement is true about abstract classes?

Intermediate
A They cannot have instance variables B They must have at least one abstract method C They cannot have static methods D They can have constructors
Show answer & explanation

They can have constructors

Abstract classes can have constructors, instance variables, and static methods; they may have zero abstract methods.

Q14. Which of the following is NOT a benefit of abstraction?

Intermediate
A It reduces complexity B It allows multiple inheritance C It enhances security by hiding details D It increases code reusability
Show answer & explanation

It allows multiple inheritance

Abstraction does not provide multiple inheritance; that is a feature of interfaces, not abstraction itself.

Topper level · 2 questions

Q15. What is the difference between an abstract class and an interface in Java?

Advanced
A Abstract classes support multiple inheritance, interfaces do not B Abstract classes can have concrete methods, interfaces can have default methods C Interfaces can have constructors, abstract classes cannot D Abstract classes can be instantiated, interfaces cannot
Show answer & explanation

Abstract classes can have concrete methods, interfaces can have default methods

Abstract classes can have concrete methods; interfaces can have default and static methods but no constructors.

Q16. Can an abstract class implement an interface without implementing its methods?

Advanced
A No, abstract classes cannot implement interfaces B No, it must implement all methods C Yes, but only if the interface has no methods D Yes, it can leave them unimplemented
Show answer & explanation

Yes, it can leave them unimplemented

An abstract class can implement an interface and leave methods unimplemented, marking them abstract.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages