Browse all practice questions for the Object‑Oriented Programming (OOP) Practice Test. Search by topic, open any question and review its full explanation, then test yourself in the practice quiz.

Object‑Oriented Programming (OOP) Practice Test course image
More practice questions

These questions are part of the practice quiz. Start practicing

  • Which principle is associated with grouping changes that happen for the same reasons?
  • How does garbage collection work in managed languages and what are typical performance considerations?
  • In Composition, does the part survive without the whole?
  • Which statement about the relationship between classes and objects is correct?
  • Which statement correctly demonstrates throwing a new exception in Java?
  • Which statement best characterizes fragility in bad software design?
  • What is the core requirement of the Acyclic Dependencies Principle?
  • Which architectural approach can help prevent cyclic dependencies by decoupling components?
  • Which form of dependency injection passes dependencies via the constructor?
  • Which collection type is ordered and allows duplicates?
  • In Java, reflection provides what capability at runtime?
  • What should you do with 'fat' interfaces?
  • How do you manually throw an exception?
  • What is the relationship between ADP and Dependency Inversion Principle (DIP)?
  • Which of the following is a primitive data type in Java?
  • Which statement best describes design patterns?
  • In Java, reflection enables what capability at runtime?
  • Which approach supports swapping implementations at runtime to ease testing?
  • Which JDBC class is used to execute parameterized SQL queries securely?
  • Which option represents a form of data hiding related to encapsulation?
  • In Java, default methods were added to interfaces in which version?
  • What does the 'final' keyword do to a class field?
  • DIP: you should depend on what?
  • What is the purpose of the Adapter pattern?
  • What is the primary purpose of mocks and stubs in unit testing?
  • REP relationship statement?
  • Explain the difference between inheritance and composition and when to prefer each.
  • What are software 'components'?
  • What are common OO code smells, and how can refactoring address them?
  • CCP is the component-level equivalent of which SOLID principle?
  • In Java, what is the blueprint from which objects are created?
  • Which practice helps prevent cycles in a dependency graph?
  • Which SOLID principle encourages splitting large interfaces into smaller, specific ones?
  • Java is primarily described as what type of programming language?
  • Which keyword is used to declare that a method may throw a checked exception?
  • How do the four access levels public, protected, private, and package-private differ in common OO languages?
  • Engine is a part of Car (Car owns Engine) — what relationship is this?
  • Method Overloading — what type of polymorphism?
  • What is a key advantage of using PreparedStatement over Statement?
  • Which statement describes the Proxy pattern?
  • How should you design custom exception types in OO languages?
  • Which statement describes aggregation?
  • Which method returns the Class object for an instance?
  • How does the Decorator pattern differ from inheritance?
  • Which scenario best illustrates the Observer pattern?
  • When using a Factory, what is a key way clients interact with produced objects?
  • What is typically overridden by subclasses in the Template Method pattern?
  • In Box<T>, what is T?
  • Why must main() always be static?
  • If a class has only a parameterized constructor and you attempt to instantiate with no arguments, what happens?
  • Which practice aligns with ADP for module interfaces?
  • Explain the Single Responsibility Principle with a concrete example.
  • In the context of the Singleton pattern, what kind of access point is typically provided?
  • Which class is considered the cosmic superclass in Java?
  • How many primitive data types are there in Java?
  • Which statement about abstract methods is true?
  • What is the difference between an abstract class and an interface, and when would you use each?
  • Which access modifier allows access in the same package and subclasses?
  • In object-oriented design, which statement best describes composition?
  • Which technique best facilitates code reuse without rigid inheritance?
  • Template Method pattern with a concrete scenario.
  • What is an abstract method?
  • Which statement best describes encapsulation in object-oriented design?
  • Which statement best describes the Diamond Problem?
  • What does the Singleton pattern guarantee?
  • What is another name for Encapsulation?
  • Why should you place close() calls in a finally block when working with JDBC resources?
  • Which statement best describes the Factory Method pattern?
  • The 'final' keyword on a method prevents what?
  • Which JDBC object represents a set of rows returned by a query?
  • Distinguish static (compile-time) polymorphism from dynamic (runtime) polymorphism with examples.
  • Why is it important to distinguish overloading and overriding when designing APIs?
  • The 'Zone of Pain' refers to which combination of abstraction and instability?
  • Which of the following is true about a class that implements an interface but does not implement all interface methods?
  • What does Fan-out measure in component design?
  • What is a common purpose of the Proxy design pattern?
  • In a generic class, what happens to type parameter when instantiated?
  • What does executeQuery() return when called on a Statement?
  • 'this' operator refers to?
  • What is a constructor, and how do default and parameterized constructors differ?
  • Which statement best describes the primary advantage of using composition over inheritance?
  • What does the 'I' in SOLID stand for?
  • What are getters and setters?
  • Arrow token in a lambda expression?
  • Which collection guarantees unique elements with no duplicates?
  • Data Abstraction is described as?
  • What is a key benefit of the Composite pattern?
  • Which of the following best describes where a static member belongs?
  • What is the Liskov Substitution Principle and how does it guide subclassing?
  • Can you instantiate an abstract class?
  • Why are unit tests and test doubles important in object-oriented development?
  • If a method declares throws IOException, what must a caller do?
  • What does immutability mean in object design, and what are its benefits?
  • What is static binding?
  • Which exception is thrown on incorrect downcasting?
  • Car has a Driver — what type of OOP relationship is this?
  • Which of the following describes checked vs unchecked exceptions?
  • The 'Zone of Uselessness' refers to which combination?
  • According to the Open-Closed Principle, how should a class be designed?
  • What is a benefit of using the Composite pattern in client code?
  • Which loop is guaranteed to execute at least once?
  • Where must super() be placed in a subclass constructor?
  • Fan-out is defined as which of the following?
  • Which statement about the nature of objects in Java is true according to the material?
  • How do abstraction and encapsulation differ, and how do they complement each other?
  • Compare composition and inheritance as design strategies and when to prefer composition?
  • What is a primary benefit of programming to interfaces rather than concrete classes?
  • What is the distinction between static members and instance members?
  • What is an exception in Java?
  • Which SOLID principle is violated when a subclass inherits a method it cannot use?
  • A component with high fan-in is typically characterized by which property?
  • What is encapsulation in object-oriented programming?
  • In SOLID, what does the L stand for?
  • How should equality and hashing be implemented in OO languages, and why must they be consistent?
  • How do interfaces enable polymorphism and support dependency injection?
  • Which keyword establishes inheritance (is-a relationship)?
  • Which construct creates a new object by copying state from an existing object using a constructor?
  • If ADP is violated, what is a common consequence?
  • Which statement best describes dependency injection?
  • Interface methods (pre-Java 8) are implicitly?
  • Which SOLID principle is about depending on abstractions rather than concretions?
  • Which statement best describes the Composite design pattern?
  • Which statement about upcasting is true?
  • If a class defines no constructor, what happens?
  • If two modules A and B depend on each other, what does that indicate in ADP terms?
  • When many other components depend on a given component, what design quality does that imply?
  • What is the Diamond Problem?
  • Which package contains the JDBC API?
  • Interface fields are implicitly what?
  • Which statement best describes a lambda expression?
  • Which JDBC object is responsible for managing database drivers?
  • In JDBC, how do you advance to the next row in a ResultSet?
  • What is method overloading, and how does the compiler choose which method to call?
  • If you declare any constructor, what happens to the default no-argument constructor?
  • Which interface enables traversal without exposing the underlying structure of a collection?
  • Three categories of Design Patterns?
  • Which statement best describes the Liskov Substitution Principle in object-oriented design?
  • What is a common strategy to break existing cyclic dependencies?
  • Which is a direct consequence of cycles in a dependency graph?
  • To whom does a static field or method belong?
  • Which statement about an abstract class is true?
  • Which block always executes after try-catch?
  • In class diagrams, how are relationships such as inheritance, association, aggregation, and composition typically represented?
  • Which principle focuses on dependency inversion by relying on abstractions rather than concrete implementations?
  • What is a Design Pattern?
  • What is upcasting?
  • Which access modifier restricts access to the same class only?
  • Data Abstraction provides what to the outside world?
  • REP (Reuse/Release Equivalence Principle) states?
  • Which coding approach helps maintain ADP in evolving codebases?
  • Which statement best describes the Strategy pattern?
  • What are generics and why are they important for type safety in OO languages?
  • What is the Builder pattern for?
  • Factory pattern advantage regarding coupling?
  • What does immobility refer to in bad software design?
  • Which statement correctly describes method overloading?
  • What is method overriding and how does the @Override annotation assist?
  • What is encapsulation primarily protecting?
  • Which of the following best describes the Decorator pattern?
  • What is a direct superclass?
  • Generics allow a single class or method to operate on different types, avoiding what?
  • Is String a primitive type in Java?
  • What must a method declare if it can throw a checked exception it doesn't catch?
  • In object-oriented design, what outcome is achieved by high cohesion and low coupling?
  • What is an indirect superclass?
  • What does statically-typed mean in Java?
  • In Box<T>, what is T called?
  • Which of the following is a reference type?
  • How many direct superclasses can a Java class have?
  • Which Statement method is used to execute a SELECT query?
  • Which pattern helps create immutable objects by assembling state at construction time?
  • Which class is at the top of the Java exception hierarchy?
  • Which description best matches the Builder's goal?
  • Which statement is true about the finally block?
  • What is covariance and contravariance in generics, and how do they affect type safety?
  • What is downcasting?
  • What does the term polymorphism literally mean?
  • What is the access modifier of the Singleton's constructor?
  • Method Overriding — what type of polymorphism?
  • What is a common benefit of enforcing ADP?
  • In (int x, int y) -> x + y, what is 'x + y'?
  • Which statement best captures the Liskov Substitution Principle?
  • Which statement describes the Object class in Java?
  • Formula for Instability (I)?
  • Differentiate shallow copy from deep copy, and give examples of when each is appropriate.
  • If a class has at least one abstract method, the class must be?
  • When making a class serializable, which concern is commonly addressed?
  • In SOLID, which principle ensures substitutability of derived classes for base classes without altering correctness?
  • What is the Open/Closed Principle and how can you implement it in OO design?
  • What does Fan-in measure in component design?
  • Under ADP, is it possible for a module to depend on many services as long as there are no cycles?
  • In terms of ADP, which statement is true about dependencies among modules?
  • CCP (Common Closure Principle) states?
  • In the SOLID design principles, what does the S stand for?
  • The 'enhanced for' loop is also known as?
  • What happens if you don't define a constructor?
  • Which operation helps determine if a dependency graph has a cycle?
  • How many interfaces can a class implement?
  • Objects from Factory are accessed through?
  • Which statement correctly describes typical elements in a class diagram and how visibility is shown?
  • What is a destructor/finalizer, and how is resource cleanup typically handled in managed languages?
  • Which SOLID principle does the Singleton pattern technically violate?
  • Which tool technique helps verify acyclic dependencies in a codebase?
  • What does JDBC stand for?
  • CRP (Common Reuse Principle) states?
  • According to SRP, how many reasons to change should a class have?
  • In UML class diagrams, what is the correct representation for aggregation vs composition?
  • Serialization is used to convert objects into a byte stream. Which concerns are commonly considered when making a class serializable?
  • What are the key components of the Command pattern?
  • I = 1 means a component is?
  • What do Generics allow programmers to avoid?
  • I = 0 means a component is?
  • Which statement correctly describes Iterable?
  • Which statement about abstract classes and interfaces is true?
  • Which collection is used to map keys to values, ensuring key uniqueness?
  • Which statement describes the Adapter pattern?
  • CRP is the component-level equivalent of which SOLID principle?
  • Which of the following is an example of runtime polymorphism in practice?
  • What is a typical sequence for refactoring a large class while preserving observable behavior?
  • What are common pitfalls of the Singleton pattern?
  • Which statement is true about a class and interfaces in Java?
  • Which statement about dynamic dispatch is true?
  • What problem can arise from multiple inheritance in object-oriented design?
  • How would you design an object oriented solution to compute areas for multiple shapes in a polymorphic way?
  • Fan-in is defined as which of the following?
  • Which statement describes the Command pattern?
  • In Aggregation, do the part and the whole survive independently?
  • Which method finalizes the object in the Builder pattern?
  • Which operator checks class membership at runtime?
  • The 'D' in SOLID stands for?
  • What happens if a method in a subclass is annotated with @Override but its signature does not match any method in the base class?
  • What cannot be declared abstract in Java?
  • What is a lambda expression?
  • Encapsulation is defined as what?
  • Which statement describes the Zone of Uselessness?
  • Which statement best captures the Liskov Substitution Principle?
Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy