← All IKM Flashcard Decks

Object-Oriented Programming Principles Flashcards

19 cards from real IKM practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 19 Object-Oriented Programming Principles flashcards as text
  1. What is encapsulation in OOP?

    Answer: Bundling data and methods while restricting access to internal state

    Encapsulation bundles data and methods within a class, hiding internal implementation.

  2. What is the difference between overloading and overriding?

    Answer: Overloading uses different parameters in same class; overriding redefines a parent method in subclass

    Overloading provides same-name methods with different parameters; overriding redefines inherited methods.

  3. What is an abstract class?

    Answer: Class that cannot be instantiated and may contain abstract methods

    Abstract classes cannot be instantiated and may have abstract methods subclasses must implement.

  4. What is the Liskov Substitution Principle?

    Answer: Subclass objects should be replaceable for superclass objects without breaking the program

    LSP states subclass objects must work wherever superclass objects are expected.

  5. What is composition over inheritance?

    Answer: Favoring has-a relationships over is-a relationships for code reuse

    Composition uses contained objects for behavior rather than extending classes.

  6. What is the purpose of an interface in OOP?

    Answer: Define a contract of methods implementing classes must provide

    An interface defines method signatures that implementing classes must provide.

  7. What is polymorphism in OOP?

    Answer: Different objects respond to the same method call differently

    Polymorphism allows different classes to provide their own implementation of shared methods.

  8. What is the Single Responsibility Principle?

    Answer: A class should have only one reason to change

    SRP means each class should have only one job or responsibility.

  9. What is a design pattern?

    Answer: Reusable solution template for common design problems

    Design patterns are general, reusable solutions to commonly occurring problems.

  10. What is the Observer design pattern?

    Answer: Subject notifies dependents of state changes

    Observer defines a one-to-many dependency where state changes trigger notifications.

  11. What is the difference between shallow and deep copy?

    Answer: Shallow copies references; deep copy recursively duplicates all nested objects

    Shallow copy shares references to nested objects; deep copy creates independent copies at every level.

  12. What is the Dependency Inversion Principle?

    Answer: High-level modules should depend on abstractions, not low-level modules

    DIP states both high and low-level modules should depend on abstractions.

  13. A Square class extends Rectangle, and Square.setWidth() also changes the height, breaking client code that expects width and height to vary independently. Which principle is violated?

    Answer: Liskov Substitution Principle

    LSP requires subtypes to be usable wherever the base type is expected without altering correct program behavior.

  14. A developer changes an internal method of a base class, and several subclasses that overrode related methods silently break. What is this problem called?

    Answer: Fragile base class problem

    The fragile base class problem occurs when seemingly safe base-class changes break subclasses that depend on its implementation details.

  15. In Java, what may an overriding method's return type be compared to the overridden method's return type?

    Answer: A subtype of the original return type

    Java supports covariant return types, so an override may return a more specific subtype.

  16. Which C++ feature ensures that a class inheriting from two classes with a common base gets only one shared copy of that base?

    Answer: Virtual inheritance

    Declaring the base with 'virtual' inheritance resolves the diamond problem by sharing one base subobject.

  17. In Java, a subclass declares a static method with the same signature as a static method in its parent. Given Parent p = new Child(); p.staticMethod(); which version runs?

    Answer: Parent's version, because static methods are hidden, not overridden

    Static methods are bound at compile time based on the declared reference type, which is called method hiding.

  18. A Printer class must implement a MultiFunctionDevice interface and throw UnsupportedOperationException for fax() and scan(). Which principle does this design violate?

    Answer: Interface Segregation Principle

    ISP states clients should not be forced to depend on methods they do not use, so the fat interface should be split.

  19. Which call chain most clearly violates the Law of Demeter?

    Answer: order.getCustomer().getAddress().getZipCode()

    The Law of Demeter says an object should talk only to its immediate collaborators, not reach through a chain of objects.

Written and edited by , founder of Practice Test Geeks, with AI assistance. Exam facts are checked against the official sources linked below. Editorial policy

Sources & references

Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy

  1. ikmnet.com — Test delivery, passing score · verified Oct 2026
  2. online.ikmnet.com — Eligibility, exam format, retake policy, score release, time limit · verified Oct 2026