Courseiva
Object-Oriented ProgrammingmediumMultiple ChoiceObjective-mapped

1Z0-811 Object-Oriented Programming Practice Question

A developer wants to create a class that can be used to represent different types of vehicles (e.g., Car, Truck, Motorcycle) and each vehicle type should be able to start its own engine in a specific way. Which OOP concept should be used to allow the vehicle class to define a common interface while letting subclasses provide specific implementations?

⚠ Common exam trap

Oracle often tests the distinction between abstraction (defining the interface) and polymorphism (using that interface to invoke different implementations at runtime), so candidates mistakenly choose abstraction when the question emphasizes 'specific implementations' and runtime behavior.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Polymorphism

Polymorphism allows the Vehicle class to define a common method (e.g., startEngine()) that each subclass (Car, Truck, Motorcycle) overrides with its own specific implementation. When the method is called on a Vehicle reference, the JVM uses dynamic method dispatch at runtime to invoke the correct subclass version, enabling different engine-starting behaviors through a single interface.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Polymorphism

    Why this is correct

    Polymorphism allows a common interface to have different implementations, achieved via method overriding.

  • Inheritance

    Why it's wrong here

    Inheritance enables code reuse but does not by itself allow runtime method selection.

  • Encapsulation

    Why it's wrong here

    Encapsulation hides data, not behavior variation.

  • Abstraction

    Why it's wrong here

    Abstraction reduces complexity by hiding implementation, but it does not provide polymorphic behavior.

About these practice questions

This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

2 more ways this is tested on 1Z0-811

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A developer writes a class 'Vehicle' with a method 'move()' that prints 'Vehicle moves'. A subclass 'Car' overrides 'move()' to print 'Car moves'. Given: Vehicle v = new Car(); v.move(); What is the output?

medium
  • A.Vehicle moves
  • B.Runtime exception
  • C.Compilation fails
  • D.Car moves

Why D: Java uses dynamic method dispatch (runtime polymorphism). Even though the reference variable is of type 'Vehicle', the actual object is a 'Car' instance. At runtime, the JVM calls the overridden 'move()' method of the 'Car' class, printing 'Car moves'.

Variation 2. Refer to the exhibit. What is the output when the following code is executed? Vehicle v = new Car(); v.accelerate(); System.out.println(v.speed);

medium
  • A.10
  • B.0
  • C.Compilation error
  • D.20

Why D: The code uses polymorphism: the reference variable v of type Vehicle points to a Car object. Since accelerate() is overridden in Car, the overridden method is invoked, adding 20 to the speed instance variable inherited from Vehicle. The protected field speed is accessible in the subclass. Therefore, after calling v.accelerate(), speed becomes 20. Option D is correct.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.