You must read Java class snippets and choose the OOP principle or access modifier that fixes the problem. The most important thing is knowing that encapsulation requires private fields with controlled access, and that polymorphism needs a superclass reference to an overridden method.
Start practicing
Object-Oriented Programming — choose a session length
Free · No account required
Domain overview
This domain covers Java's object-oriented core: defining classes with fields and methods, access modifiers, encapsulation, inheritance, polymorphism, and package declarations. Questions present short code snippets or design scenarios where you identify the OOP principle violated or the reason code compiles or fails.
Exam objectives
Applying encapsulation with private fields and public getter/setter methods in Java classes
Recognizing polymorphism through superclass references and overridden subclass methods
Using access modifiers (public, private, protected, default) and package declarations correctly
Explaining why public fields violate data hiding and allow invalid state changes
Assuming a class with no access modifier is public; default access limits visibility to the same package, causing compilation errors elsewhere.
Confusing method overloading with overriding; polymorphism requires a superclass reference and a subclass override, not just same-named methods.
Thinking public fields are acceptable if constructors validate input; direct field access still bypasses validation and breaks encapsulation.
Click any question to see the full explanation and answer options, or start a focused practice session above.
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?
2In a banking application, a class 'Account' has a private field 'balance'. Which is the best way to allow subclasses to read but not directly modify 'balance'?
3A class 'Base' has a method 'public void display() throws IOException'. Subclass 'Derived' overrides display(). Which exception specifications are allowed in the overriding method?
4Which design principle is violated by making all fields public in a class?
5Which is the correct way to call a superclass constructor from a subclass constructor?
6A developer wants to prevent a method from being overridden. Which modifier should be used?
7Which TWO statements are true about interfaces in Java?
8Which THREE are benefits of using inheritance?
9A development team is building a library management system. The system has classes 'LibraryItem', 'Book', and 'DVD'. LibraryItem has a method 'getTitle()' that returns the title. Book and DVD extend LibraryItem. The team wants to ensure that when a LibraryItem is borrowed, a message specific to its type is displayed. They have a 'Borrower' class with a method 'borrow(LibraryItem item)', which currently calls 'item.getTitle()' and prints the title. Now they need to display 'Book borrowed' or 'DVD borrowed' based on the actual item type. They want to avoid using 'instanceof' checks in the 'borrow' method to keep it open for new item types. Which design should they use?
10Arrange the steps to implement an interface in a Java class in the correct order.
11Match each Java exception class to its category.
12A company is developing a configuration manager that must be shared across all components to ensure consistent settings. The manager should prevent direct instantiation and provide a single access point. Which design pattern and implementation should be used?
13A junior developer writes a method that attempts to modify a String: public void update() { String s = "Hello"; s.concat(" World"); System.out.println(s); } What will be printed when update() is called?
14A banking application has a base class 'Account' with a method 'withdraw()' marked as final. A subclass 'SavingsAccount' tries to override 'withdraw()'. What is the outcome?
15A company's HR system uses an Employee class with sensitive salary information. The team wants to allow other classes to read the salary but not modify it. Which approach best preserves encapsulation?
16A developer creates an interface 'Drawable' with a single abstract method 'draw()'. They then create a class 'Circle' that implements Drawable but forgets to provide the draw() method. Circle is not declared abstract. What will happen when compiling Circle?
17A security-sensitive class should not be extended by any other class. Which modifier should be applied to the class declaration?
18A logging utility class keeps track of the number of log entries using a static integer variable. The class is instantiated multiple times in the application. How does the count variable behave?
19A calculator class has two overloaded methods: add(int a, int b) and add(double a, double b). A call to add(3, 4) will invoke which method?
20A developer writes a class 'Animal' with a method 'sound()'. The 'Cat' subclass overrides 'sound()'. If an Animal reference points to a Cat object, which method is called when sound() is invoked?
21Which two of the following are fundamental principles of Object-Oriented Programming? (Choose two.)
22A developer wants to achieve loose coupling between components. Which two practices support loose coupling? (Choose two.)
23Which three statements about constructors in Java are true? (Choose three.)
24Refer to the exhibit. What is the potential issue with this singleton implementation in a multithreaded environment?
25A developer wants to ensure that a class cannot be subclassed. Which keyword should be used?
26A class has a method that is marked as protected. Which statement is true about its accessibility?
27Which access modifier allows a member to be accessed only within the same class?
28A developer writes: Object obj = new String("Hello"); System.out.println(obj.length()); What will be the output?
29Which of the following best demonstrates polymorphism in Java?
30A class that does not define any constructor has:
31class Parent { void show() { System.out.print("Parent"); } } class Child extends Parent { void show() { System.out.print("Child"); } } public class Test { public static void main(String[] args) { Parent p = new Child(); p.show(); } } What is the output?
32Which TWO access modifiers allow access from a subclass in a different package?
33Which THREE are true about Java constructors?
34Which TWO statements about interfaces in Java are true?
35A Java class named 'Helper' is defined in package 'utils'. Another class in a different package tries to access a public method of Helper but receives a compilation error. The Helper class is declared as 'class Helper' (without public modifier). What is the likely issue?
36In a banking application, a class 'Account' has private field 'balance' and public methods 'getBalance()' and 'setBalance(double)'. This is an example of which OOP principle?
37A team is designing a system where a 'Report' class can be generated in different formats (PDF, Excel, HTML). They want to avoid modifying the Report class when adding new formats. Which OOP principle or pattern should they use?
38A class 'Animal' has a method 'makeSound()'. Subclasses 'Dog' and 'Cat' override it. When calling makeSound() on an Animal reference that actually holds a Dog object, the Dog's version is executed. This is an example of:
39A Java application uses an interface 'Drawable' with a default method 'draw()'. A class 'Circle' implements Drawable but does not override draw(). Another class 'Square' implements Drawable and overrides draw(). Which statement is true about calling draw() on instances of Circle and Square?
40Which TWO of the following are valid benefits of using inheritance in Java? (Choose two.)
41Which THREE statements are true about interfaces in Java? (Choose three.)
42A team is developing a large-scale e-commerce platform using Java. They have a class hierarchy: Product (abstract), Electronics, Clothing, Food. Each product has a discount method that applies different logic. The team notices that whenever a new product type is added, they must modify the existing discount calculation logic in multiple places, leading to high maintenance costs. They want to refactor to follow the Open/Closed Principle. Which approach should they take?
43A developer is working on a Java application that processes sensor data. The code uses a class 'SensorDataProcessor' which directly instantiates specific sensor classes like 'TemperatureSensor' and 'PressureSensor' inside its methods. The team wants to make the system extensible to support new sensor types without modifying the processor class. Which design change best achieves this?
44A junior developer created a class 'BankAccount' with public fields for balance and account number. After deployment, users are able to set negative balances, causing issues. Which OOP principle should have been applied to prevent this?
45In a Java application, a class 'OrderProcessor' contains a method that processes orders. The method currently handles multiple responsibilities: validating order data, calculating totals, updating inventory, and sending notifications. The team wants to refactor this method to follow the Single Responsibility Principle. Which action should they take?
46Which TWO statements are true about the 'super' keyword in Java?
47A developer defines an abstract class 'Shape' with an abstract method 'area()' and a concrete method 'describe()'. A subclass 'Rectangle' extends 'Shape' and provides an implementation of 'area()' but does not override 'describe()'. A program creates a 'Rectangle' object and calls both methods. What is the result?
48A developer defines a class Shape with a protected method area() and a public method describe() that calls area(). A subclass Circle overrides area() but does not override describe(). A Circle object is created and describe() is invoked. What happens?
49A developer wants to model a class Employee that stores a name and a salary. The class should prevent direct modification of salary from outside the class, while allowing read access. Which design best satisfies this requirement?
50A developer is designing a Shape class hierarchy for a graphics editor. The Shape class declares a method public double area() that returns 0.0. The Circle subclass provides its own area() implementation. When the developer writes Shape s = new Circle(2.0); System.out.println(s.area()); the program prints the circle's area. Which OOP concept does this behavior demonstrate?
51A class Vehicle has a constructor that takes an int parameter. A subclass Car has a constructor that takes an int parameter and needs to initialize the inherited part using the Vehicle constructor. Which statement about constructor chaining is correct?
52A developer writes a class named Employee that declares a public method named calculatePay. A second class named Manager extends Employee and declares its own public method named calculatePay with the exact same name, parameter list, and return type. At runtime, a Manager object assigned to an Employee reference is used to invoke calculatePay. Which concept does this scenario describe?
53A developer writes a class Employee with fields name and salary. The developer wants other classes to read and modify these fields only through methods that enforce validation rules, and wants to prevent direct field access from outside the class. Which pair of keywords should be applied to the fields and the accessor methods respectively to achieve this?
54A developer defines an abstract class named Vehicle with an abstract method move and a concrete method describe. A class named Bicycle extends Vehicle but does not implement move. What is the result when the developer attempts to compile Bicycle?
55A development team is refactoring a Java application and must decide where to use abstract classes versus interfaces. Which two statements correctly describe legal and meaningful usage of an abstract class in Java? (Choose two.)
56A developer designs a class named BankAccount that stores a private field accountNumber. The field must never be modified after the constructor runs, and other classes must be able to read its value. Which declaration best satisfies these requirements?
57A developer writes a class Logger with a private static Logger instance and a public static Logger getInstance() method. The method checks if instance is null and creates it. Two threads call getInstance() simultaneously on first use. What is the most likely problem?
58A developer defines an interface named Payable with the single method double calculatePay(). A class Contractor is declared as public class Contractor implements Payable but provides no calculatePay() method and is not marked abstract. What is the result when the developer compiles Contractor?
59A developer is defining a Java interface named Payable that declares a method processPayment. The developer wants to ensure that any implementing class provides a concrete implementation of processPayment while the interface itself remains abstract. Which TWO statements about this interface design are true? (Choose two.)
60A developer writes a class Vehicle with a protected method startEngine(). A class Car in a different package extends Vehicle. Inside a method of Car, the developer attempts to call startEngine() on a Vehicle reference variable named v. What happens at compile time?
61A developer is writing a payroll system. The class `Employee` has a method `calculatePay()`, and the subclass `Manager` overrides it to add a bonus. The developer writes `Employee e = new Manager();` and then calls `e.calculatePay();`. Which statement describes what happens at runtime?
62A developer defines an interface `Printable` with a single method `void print()`. A class `Report` implements `Printable` but declares the method as `public void print() throws IOException`. The developer compiles the code and receives a compiler error. What is the reason?
63A developer writes a class `Counter` with a private static int field `count` and an instance method `increment()` that performs `count++`. The developer creates three separate Counter objects and calls `increment()` on each one once. What is the value of count after all three calls?
64A developer is designing a Java application with an interface `Vehicle` and several implementing classes. Which two statements about interface implementation are correct? (Choose two.)
65A developer writes a class named Shape with a method area that returns a double. A subclass named Circle overrides area to compute the circle's area. A variable of type Shape is assigned a new Circle object, and area is invoked on that variable. Which statement correctly describes how the method call is resolved?
Deep-dive questions
The most-searched questions in this domain — detailed explanations, worked examples, full answer breakdowns.
You must read Java class snippets and choose the OOP principle or access modifier that fixes the problem. The most important thing is knowing that encapsulation requires private fields with controlled access, and that polymorphism needs a superclass reference to an overridden method.
The Courseiva 1Z0-811 question bank contains 65 questions in the Object-Oriented Programming domain, covering the 14% of the exam attributed to this domain in the official Oracle blueprint. Click any question to see the full explanation and answer breakdown.
Start with a 10-question focused session to identify your baseline accuracy in this domain. Read every explanation — even for questions you answer correctly — to understand the reasoning. Once you score consistently above 80%, move to a 20–30 question session to confirm depth before moving to the next domain.
Yes — the session launcher on this page draws questions exclusively from the Object-Oriented Programming domain. Choose 10, 20, 30, or 50 questions for a focused session, or click individual questions to review them one by one.
Save your results, see per-domain analytics, and get readiness scores — free, for every certification.
Sign Up FreeFree forever · Every certification included