Skip to content

Consolidated Java OOP Interview QuestionsΒΆ

OrganizationΒΆ

  • Grouped by OOP subtopic.
  • Ordered from Beginner β†’ Intermediate β†’ Advanced β†’ Expert.
  • No question wording has been changed or removed.
  • The repeated Core 51 and Scenario 14 sets in the source are retained as separate copies.
  • Original source numbering is retained in the Source label only; the question text itself is preserved.

1. OOP Fundamentals / Classes, Objects & LifecycleΒΆ

1. OOP Fundamentals / Classes, Objects & LifecycleΒΆ

BeginnerΒΆ

  1. Source: Original 175 #1 What is Object-Oriented Programming (OOP)?

  2. Source: Original 175 #2 What are the four pillars of OOP?

  3. Source: Original 175 #3 What is the difference between a class and an object?

  4. Source: Original 175 #4 What is the difference between an object-oriented language and an object-based language?

  5. Source: Original 175 #5 Why is Java considered an object-oriented programming language?

  6. Source: Original 175 #6 Is Java a 100% pure object-oriented language? Why or why not?

  7. Source: Original 175 #7 What are the advantages of OOP?

  8. Source: Original 175 #8 What is the relationship between a class and an object?

  9. Source: Original 175 #9 Can you explain OOP using a real-world example?

  10. Source: Original 175 #10 What is the difference between state and behavior of an object?

  11. Source: Core 51 β€” copy 1 #1 What is the fundamental difference between a Class and an Object?

  12. Source: Core 51 β€” copy 1 #2 Why is Java considered a "semi-pure" or not a "pure" Object-Oriented language?

  13. Source: Core 51 β€” copy 1 #3 Explain the functionality of the public static void main(String[] args) method structure.

  14. Source: Core 51 β€” copy 1 #4 What are the default values assigned to instance variables versus local variables in Java?

  15. Source: Core 51 β€” copy 1 #5 How does the Java String Pool interact with standard object allocation in heap memory?

  16. Source: Core 51 β€” copy 2 #1 What is the fundamental difference between a Class and an Object?

  17. Source: Core 51 β€” copy 2 #2 Why is Java considered a "semi-pure" or not a "pure" Object-Oriented language?

  18. Source: Core 51 β€” copy 2 #3 Explain the functionality of the public static void main(String[] args) method structure.

  19. Source: Core 51 β€” copy 2 #4 What are the default values assigned to instance variables versus local variables in Java?

  20. Source: Core 51 β€” copy 2 #5 How does the Java String Pool interact with standard object allocation in heap memory?

IntermediateΒΆ

  1. Source: Original 175 #11 What is the difference between an object and a reference variable in Java?

  2. Source: Original 175 #12 What happens when you create an object using the new keyword?

  3. Source: Original 175 #13 Can an object exist without a reference variable?

  4. Source: Original 175 #14 What is object identity in Java?

  5. Source: Original 175 #15 What is the difference between IS-A and HAS-A relationships?

  6. Source: Core 51 β€” copy 1 #6 What are the different ways to create an object in Java without using the new keyword?

  7. Source: Core 51 β€” copy 1 #7 Explain the structural difference between Stack memory and Heap memory allocations during object initialization.

  8. Source: Core 51 β€” copy 1 #8 Does setting an object reference to null trigger instant Garbage Collection? Explain the underlying mechanism.

  9. Source: Core 51 β€” copy 1 #9 What is an Anonymous Inner Class, and what is its standard compilation footprint?

  10. Source: Core 51 β€” copy 1 #10 Can you create a class that contains exclusively static members? Is this design truly object-oriented?

  11. Source: Core 51 β€” copy 2 #6 What are the different ways to create an object in Java without using the new keyword?

  12. Source: Core 51 β€” copy 2 #7 Explain the structural difference between Stack memory and Heap memory allocations during object initialization.

  13. Source: Core 51 β€” copy 2 #8 Does setting an object reference to null trigger instant Garbage Collection? Explain the underlying mechanism.

  14. Source: Core 51 β€” copy 2 #9 What is an Anonymous Inner Class, and what is its standard compilation footprint?

  15. Source: Core 51 β€” copy 2 #10 Can you create a class that contains exclusively static members? Is this design truly object-oriented?

ExpertΒΆ

  1. Source: Original 175 #16 How do you decide whether a concept should be modeled as a class, interface, or enum?

  2. Source: Original 175 #17 How do you identify good object boundaries when designing a Java application?

  3. Source: Original 175 #18 What makes an object-oriented design maintainable and extensible?

  4. Source: Core 51 β€” copy 1 #11 How can you programmatically prevent a class from being instantiated while still allowing it to have sub-classes?

  5. Source: Core 51 β€” copy 1 #12 Deeply analyze how java.lang.ClassLoader loads a class into memory and constructs its metadata objects.

  6. Source: Core 51 β€” copy 1 #13 How do you design and structure a strictly thread-safe Immutable Class in Java?

  7. Source: Core 51 β€” copy 2 #11 How can you programmatically prevent a class from being instantiated while still allowing it to have sub-classes?

  8. Source: Core 51 β€” copy 2 #12 Deeply analyze how java.lang.ClassLoader loads a class into memory and constructs its metadata objects.

  9. Source: Core 51 β€” copy 2 #13 How do you design and structure a strictly thread-safe Immutable Class in Java?

2. Encapsulation & Data HidingΒΆ

BeginnerΒΆ

  1. Source: Original 175 #19 What is encapsulation in Java?

  2. Source: Original 175 #20 How do you achieve encapsulation in Java?

  3. Source: Original 175 #21 Why are instance variables generally declared private?

  4. Source: Original 175 #22 What is data hiding?

  5. Source: Original 175 #23 What is the difference between encapsulation and data hiding?

  6. Source: Original 175 #24 Why do we use getters and setters?

  7. Source: Original 175 #25 Can encapsulation be achieved without getters and setters?

  8. Source: Core 51 β€” copy 1 #14 What is Encapsulation, and how do access modifiers help enforce it?

  9. Source: Core 51 β€” copy 1 #15 What is the explicit default access modifier of a class member if none is assigned?

  10. Source: Core 51 β€” copy 1 #16 What are the differences between standard Getters/Setters and direct public attribute access?

  11. Source: Core 51 β€” copy 2 #14 What is Encapsulation, and how do access modifiers help enforce it?

  12. Source: Core 51 β€” copy 2 #15 What is the explicit default access modifier of a class member if none is assigned?

  13. Source: Core 51 β€” copy 2 #16 What are the differences between standard Getters/Setters and direct public attribute access?

IntermediateΒΆ

  1. Source: Original 175 #26 Is a class properly encapsulated if all its fields are private but its getter returns a mutable object?

  2. Source: Original 175 #27 How would you make a Java class truly encapsulated?

  3. Source: Original 175 #28 What is the difference between a mutable and immutable object?

  4. Source: Original 175 #29 How does immutability strengthen encapsulation?

  5. Source: Original 175 #30 How would you design an immutable Employee class?

  6. Source: Core 51 β€” copy 1 #17 Why is true encapsulation violated if your getter method returns a direct reference to a mutable private collection?

  7. Source: Core 51 β€” copy 1 #18 Explain the concrete difference between a data-hiding module and a simple Data Transfer Object (DTO).

  8. Source: Core 51 β€” copy 1 #19 How do access specifiers function across distinct packages and subclasses in Java?

  9. Source: Core 51 β€” copy 2 #17 Why is true encapsulation violated if your getter method returns a direct reference to a mutable private collection?

  10. Source: Core 51 β€” copy 2 #18 Explain the concrete difference between a data-hiding module and a simple Data Transfer Object (DTO).

  11. Source: Core 51 β€” copy 2 #19 How do access specifiers function across distinct packages and subclasses in Java?

ExpertΒΆ

  1. Source: Original 175 #31 Suppose your class contains List<Address> internally. How can you prevent callers from modifying your internal state?

  2. Source: Original 175 #32 What is defensive copying, and why is it important for encapsulation?

  3. Source: Original 175 #33 Can excessive use of getters/setters be considered poor object-oriented design? Why?

  4. Source: Original 175 #34 How would you prevent an object's internal state from being exposed through an API?

  5. Source: Original 175 #165 Design a BankAccount class where users cannot directly modify the balance. How would you achieve proper encapsulation?

  6. Source: Original 175 #166 You have an Employee object containing id, name, Address, and List<String> phoneNumbers. How would you make the entire object immutable?

  7. Source: Core 51 β€” copy 1 #20 How does the Java 9+ Module System (module-info.java) alter traditional encapsulation boundaries at the JAR level?

  8. Source: Core 51 β€” copy 1 #21 How can a malicious actor bypass class-level encapsulation via Java Reflection API, and how do you prevent it?

  9. Source: Core 51 β€” copy 2 #20 How does the Java 9+ Module System (module-info.java) alter traditional encapsulation boundaries at the JAR level?

  10. Source: Core 51 β€” copy 2 #21 How can a malicious actor bypass class-level encapsulation via Java Reflection API, and how do you prevent it?

  11. Source: Scenario 14 β€” copy 1 #8 The Healthcare Patient PII Leak and Data Hiding

  12. Scenario: A clinical application logs transaction payloads for debugging purposes. A junior engineer prints a full Patient object via System.out.println(), accidentally exposing sensitive medical histories in the unencrypted app logs.
  13. Question: How would you override the .toString() method of the object, using Data Abstraction, to display generic tracking metadata while cleanly redacting all PII fields?

  14. Source: Scenario 14 β€” copy 1 #14 The High-Throughput Fintech Order Matching Object Pool Engine

  15. Scenario: A high-frequency trading application experiences severe latency spikes during market open due to excessive JVM garbage collection pauses caused by allocating millions of short-lived trade objects.
  16. Question: How would you apply Encapsulation and object lifecycle control to design an Object Pool, recycling instances to prevent heap memory exhaustion?

  17. Source: Scenario 14 β€” copy 2 #8 The Healthcare Patient PII Leak and Data Hiding

  18. Scenario: A clinical application logs transaction payloads for debugging purposes. A junior engineer prints a full Patient object via System.out.println(), accidentally exposing sensitive medical histories in the unencrypted app logs.
  19. Question: How would you override the .toString() method of the object, using Data Abstraction, to display generic tracking metadata while cleanly redacting all PII fields?

  20. Source: Scenario 14 β€” copy 2 #14 The High-Throughput Fintech Order Matching Object Pool Engine

  21. Scenario: A high-frequency trading application experiences severe latency spikes during market open due to excessive JVM garbage collection pauses caused by allocating millions of short-lived trade objects.
  22. Question: How would you apply Encapsulation and object lifecycle control to design an Object Pool, recycling instances to prevent heap memory exhaustion?

3. InheritanceΒΆ

BeginnerΒΆ

  1. Source: Original 175 #35 What is inheritance in Java?

  2. Source: Original 175 #36 Why do we use inheritance?

  3. Source: Original 175 #37 What is the syntax for implementing inheritance in Java?

  4. Source: Original 175 #38 What types of inheritance are supported by Java?

  5. Source: Original 175 #39 Does Java support multiple inheritance through classes? Why not?

  6. Source: Original 175 #40 What is the difference between extends and implements?

  7. Source: Original 175 #41 What is an IS-A relationship?

  8. Source: Original 175 #42 What is the purpose of the super keyword?

  9. Source: Original 175 #43 Can a child class access private members of its parent class?

  10. Source: Original 175 #44 Can a constructor be inherited?

  11. Source: Original 175 #45 Can a final class be inherited?

  12. Source: Core 51 β€” copy 1 #22 What is the use of the super keyword in Java constructors and methods?

  13. Source: Core 51 β€” copy 1 #23 Why does Java explicitly prohibit multiple inheritance with classes?

  14. Source: Core 51 β€” copy 1 #24 What is the fundamental design difference between single inheritance and multilevel inheritance?

  15. Source: Core 51 β€” copy 2 #22 What is the use of the super keyword in Java constructors and methods?

  16. Source: Core 51 β€” copy 2 #23 Why does Java explicitly prohibit multiple inheritance with classes?

  17. Source: Core 51 β€” copy 2 #24 What is the fundamental design difference between single inheritance and multilevel inheritance?

IntermediateΒΆ

  1. Source: Original 175 #46 What happens when a child class does not explicitly call the parent constructor?

  2. Source: Original 175 #47 What is constructor chaining?

  3. Source: Original 175 #48 What is the difference between this() and super()?

  4. Source: Original 175 #49 Can a class extend one class and implement multiple interfaces?

  5. Source: Original 175 #50 Can an abstract class extend another abstract class?

  6. Source: Original 175 #51 Can an abstract class extend a concrete class?

  7. Source: Original 175 #52 Can an interface extend another interface?

  8. Source: Original 175 #53 Can an interface extend multiple interfaces?

  9. Source: Original 175 #54 Why does Java avoid multiple inheritance with classes?

  10. Source: Original 175 #55 What is the diamond problem?

  11. Source: Original 175 #56 How does Java resolve the diamond problem with default interface methods?

  12. Source: Core 51 β€” copy 1 #25 Differentiate between Association, Aggregation, and Composition using real-world software components.

  13. Source: Core 51 β€” copy 1 #26 If a base class lacks a default no-argument constructor, what mandatory design steps must the subclass follow?

  14. Source: Core 51 β€” copy 1 #27 Why are constructors strictly excluded from inheritance in Java?

  15. Source: Core 51 β€” copy 2 #25 Differentiate between Association, Aggregation, and Composition using real-world software components.

  16. Source: Core 51 β€” copy 2 #26 If a base class lacks a default no-argument constructor, what mandatory design steps must the subclass follow?

  17. Source: Core 51 β€” copy 2 #27 Why are constructors strictly excluded from inheritance in Java?

ExpertΒΆ

  1. Source: Original 175 #57 When should you prefer composition over inheritance?

  2. Source: Original 175 #58 What are the disadvantages of deep inheritance hierarchies?

  3. Source: Original 175 #59 How can inheritance violate the Liskov Substitution Principle?

  4. Source: Original 175 #60 What problems can arise when a base class is modified after many subclasses already exist?

  5. Source: Original 175 #61 What is fragile base class problem?

  6. Source: Original 175 #62 How would you refactor an inheritance-heavy design into composition?

  7. Source: Core 51 β€” copy 1 #28 Explain the Diamond Problem in C++ and analyze step-by-step how Java resolves it when utilizing Interface Default Methods.

  8. Source: Core 51 β€” copy 1 #29 How does Object composition provide greater runtime flexibility over rigid Class Inheritance?

  9. Source: Core 51 β€” copy 2 #28 Explain the Diamond Problem in C++ and analyze step-by-step how Java resolves it when utilizing Interface Default Methods.

  10. Source: Core 51 β€” copy 2 #29 How does Object composition provide greater runtime flexibility over rigid Class Inheritance?

  11. Source: Scenario 14 β€” copy 1 #5 The Multi-Tier Logistics Dynamic Pricing Calculator

  12. Scenario: A logistics platform calculates shipping rates. Standard shipping uses a fixed pricing formula. Express shipping builds upon standard pricing but injects fuel surcharge logic. Same-day delivery adds urgent courier dispatch tariffs.
  13. Question: Formulate an elegant solution using Multilevel Inheritance and Method Overriding, illustrating how to reuse the base cost calculation while modifying the specific variable adjustments.

  14. Source: Scenario 14 β€” copy 2 #5 The Multi-Tier Logistics Dynamic Pricing Calculator

  15. Scenario: A logistics platform calculates shipping rates. Standard shipping uses a fixed pricing formula. Express shipping builds upon standard pricing but injects fuel surcharge logic. Same-day delivery adds urgent courier dispatch tariffs.
  16. Question: Formulate an elegant solution using Multilevel Inheritance and Method Overriding, illustrating how to reuse the base cost calculation while modifying the specific variable adjustments.

4. Association, Aggregation & CompositionΒΆ

IntermediateΒΆ

  1. Source: Original 175 #116 What is association between two classes?

  2. Source: Original 175 #117 What is aggregation?

  3. Source: Original 175 #118 What is composition?

  4. Source: Original 175 #119 What is the difference between aggregation and composition?

  5. Source: Original 175 #120 What is the difference between inheritance and composition?

  6. Source: Original 175 #121 What does HAS-A mean?

  7. Source: Original 175 #122 Give a real-world example of composition.

  8. Source: Original 175 #123 Give a real-world example of aggregation.

  9. Source: Original 175 #124 If a Car contains an Engine, should this be inheritance or composition? Why?

  10. Source: Original 175 #125 When would you choose composition over inheritance?

ExpertΒΆ

  1. Source: Original 175 #163 You have Employee, Manager, Developer, and Tester. When would you use inheritance, and when would you use composition?

  2. Source: Original 175 #170 Design a ride-booking system supporting Bike, Car, Auto, and Truck. How would you model the common behavior and vehicle-specific behavior?

  3. Source: Scenario 14 β€” copy 1 #3 The Scalable FinTech Banking Notification Framework

  4. Scenario: A core banking service must broadcast real-time user events (SMS, Email, Push Notifications) concurrently based on specific user configurations.
  5. Question: Design a completely decoupled system architecture utilizing Interfaces and the Observer Pattern to demonstrate how to attach or detach notification channels at runtime.

  6. Source: Scenario 14 β€” copy 1 #11 The Media Streaming Platform Audio/Video Processing Pipeline

  7. Scenario: A content platform processes video uploads. High-res videos are broken into distinct video, audio, and subtitle streams, which are compressed using specialized codecs.
  8. Question: Show how to build an ingestion worker using Composition rather than Inheritance, demonstrating how to swap audio and video encoders at runtime without rebuilding the class architecture.

  9. Source: Scenario 14 β€” copy 2 #3 The Scalable FinTech Banking Notification Framework

  10. Scenario: A core banking service must broadcast real-time user events (SMS, Email, Push Notifications) concurrently based on specific user configurations.
  11. Question: Design a completely decoupled system architecture utilizing Interfaces and the Observer Pattern to demonstrate how to attach or detach notification channels at runtime.

  12. Source: Scenario 14 β€” copy 2 #11 The Media Streaming Platform Audio/Video Processing Pipeline

  13. Scenario: A content platform processes video uploads. High-res videos are broken into distinct video, audio, and subtitle streams, which are compressed using specialized codecs.
  14. Question: Show how to build an ingestion worker using Composition rather than Inheritance, demonstrating how to swap audio and video encoders at runtime without rebuilding the class architecture.

5. Polymorphism & Method BindingΒΆ

BeginnerΒΆ

  1. Source: Original 175 #63 What is polymorphism?

  2. Source: Original 175 #64 What are the types of polymorphism in Java?

  3. Source: Original 175 #65 What is compile-time polymorphism?

  4. Source: Original 175 #66 What is runtime polymorphism?

  5. Source: Original 175 #67 What is method overloading?

  6. Source: Original 175 #68 What is method overriding?

  7. Source: Original 175 #69 What is the difference between overloading and overriding?

  8. Source: Original 175 #70 Give a real-world example of polymorphism.

  9. Source: Core 51 β€” copy 1 #30 What is the core difference between Method Overloading and Method Overriding?

  10. Source: Core 51 β€” copy 1 #31 What is the difference between Compile-time (Static) and Runtime (Dynamic) polymorphism?

  11. Source: Core 51 β€” copy 1 #32 Can you overload the Java main() method?

  12. Source: Core 51 β€” copy 2 #30 What is the core difference between Method Overloading and Method Overriding?

  13. Source: Core 51 β€” copy 2 #31 What is the difference between Compile-time (Static) and Runtime (Dynamic) polymorphism?

  14. Source: Core 51 β€” copy 2 #32 Can you overload the Java main() method?

IntermediateΒΆ

  1. Source: Original 175 #71 Can we overload a method by changing only its return type?

  2. Source: Original 175 #72 Can we overload static methods?

  3. Source: Original 175 #73 Can we override static methods?

  4. Source: Original 175 #74 What is method hiding?

  5. Source: Original 175 #75 Can we override a private method?

  6. Source: Original 175 #76 Can we override a final method?

  7. Source: Original 175 #77 Can we override a constructor?

  8. Source: Original 175 #78 Can constructors be overloaded?

  9. Source: Original 175 #79 Can the main() method be overloaded?

  10. Source: Original 175 #80 What is dynamic method dispatch?

  11. Source: Original 175 #81 How does Java determine which overridden method should execute?

  12. Source: Original 175 #82 What is the difference between early binding and late binding?

  13. Source: Core 51 β€” copy 1 #33 Can you override a static or a private method in Java? Explain the exact compilation behavior.

  14. Source: Core 51 β€” copy 1 #34 What is Method Hiding in Java, and how does it distinctively differ from Method Overriding?

  15. Source: Core 51 β€” copy 1 #35 What are Covariant Return Types, and how do they enhance flexibility in method overriding?

  16. Source: Core 51 β€” copy 2 #33 Can you override a static or a private method in Java? Explain the exact compilation behavior.

  17. Source: Core 51 β€” copy 2 #34 What is Method Hiding in Java, and how does it distinctively differ from Method Overriding?

  18. Source: Core 51 β€” copy 2 #35 What are Covariant Return Types, and how do they enhance flexibility in method overriding?

ExpertΒΆ

  1. Source: Original 175 #83 What happens when a parent reference points to a child object?

  2. Source: Original 175 #84 In Parent p = new Child(), which methods and variables are resolved at compile time and which at runtime?

  3. Source: Original 175 #85 What happens when a parent reference calls an overridden method?

  4. Source: Original 175 #86 What happens when a parent reference tries to access a child-specific method?

  5. Source: Original 175 #87 What is a covariant return type?

  6. Source: Original 175 #88 Can an overridden method reduce the visibility of the parent method? Why not?

  7. Source: Original 175 #89 What are the rules for checked exceptions when overriding a method?

  8. Source: Original 175 #90 How does polymorphism enable loose coupling?

  9. Source: Original 175 #91 How does dependency injection make use of polymorphism?

  10. Source: Original 175 #164 An e-commerce application has different discount rules for Premium customers, regular customers and corporate customers. How would you design this using polymorphism rather than a huge if-else block?

  11. Source: Core 51 β€” copy 1 #36 Explain how the Java Virtual Machine (JVM) performs dynamic method dispatch internally using Virtual Method Tables (VMT).

  12. Source: Core 51 β€” copy 1 #37 If an overridden method throws a checked exception, what strict restrictions apply to the subclass method's exception signature?

  13. Source: Core 51 β€” copy 2 #36 Explain how the Java Virtual Machine (JVM) performs dynamic method dispatch internally using Virtual Method Tables (VMT).

  14. Source: Core 51 β€” copy 2 #37 If an overridden method throws a checked exception, what strict restrictions apply to the subclass method's exception signature?

  15. Source: Scenario 14 β€” copy 1 #1 The Resilient E-Commerce Payment Gateway Engine

  16. Scenario: You are building a payment engine processing credit cards, UPI, and crypto.
  17. Question: How do you use the Strategy Design Pattern combined with Polymorphism to dynamically add new payment rails without altering or breaking existing core transactional pipelines?

  18. Source: Scenario 14 β€” copy 1 #12 The Telemetry Dashboard Event Overload Ingestion Crash

  19. Scenario: An analytics engine accepts diverse metrics data packages (JSON, plain text, XML payloads) from server farms.
  20. Question: How would you use Method Overloading to provide a clean, single-point entry pipeline called processMetric() that handles different argument variations elegantly at compile time?

  21. Source: Scenario 14 β€” copy 2 #1 The Resilient E-Commerce Payment Gateway Engine

  22. Scenario: You are building a payment engine processing credit cards, UPI, and crypto.
  23. Question: How do you use the Strategy Design Pattern combined with Polymorphism to dynamically add new payment rails without altering or breaking existing core transactional pipelines?

  24. Source: Scenario 14 β€” copy 2 #12 The Telemetry Dashboard Event Overload Ingestion Crash

  25. Scenario: An analytics engine accepts diverse metrics data packages (JSON, plain text, XML payloads) from server farms.
  26. Question: How would you use Method Overloading to provide a clean, single-point entry pipeline called processMetric() that handles different argument variations elegantly at compile time?

6. Abstraction, Interfaces & Abstract ClassesΒΆ

BeginnerΒΆ

  1. Source: Original 175 #92 What is abstraction in Java?

  2. Source: Original 175 #93 Why do we need abstraction?

  3. Source: Original 175 #94 How can abstraction be achieved in Java?

  4. Source: Original 175 #95 What is an abstract class?

  5. Source: Original 175 #96 What is an abstract method?

  6. Source: Original 175 #97 Can we create an object of an abstract class?

  7. Source: Original 175 #98 Can an abstract class have constructors?

  8. Source: Original 175 #99 Can an abstract class have non-abstract methods?

  9. Source: Original 175 #100 Can an abstract class contain variables?

  10. Source: Core 51 β€” copy 1 #38 What is Abstraction, and how does it fundamentally differ from Encapsulation?

  11. Source: Core 51 β€” copy 1 #39 Can you instantiate an Abstract Class? Can an Abstract Class contain a constructor?

  12. Source: Core 51 β€” copy 1 #40 How does a Java Interface help achieve 100% architectural abstraction?

  13. Source: Core 51 β€” copy 2 #38 What is Abstraction, and how does it fundamentally differ from Encapsulation?

  14. Source: Core 51 β€” copy 2 #39 Can you instantiate an Abstract Class? Can an Abstract Class contain a constructor?

  15. Source: Core 51 β€” copy 2 #40 How does a Java Interface help achieve 100% architectural abstraction?

IntermediateΒΆ

  1. Source: Original 175 #101 What is an interface?

  2. Source: Original 175 #102 What is the difference between an abstract class and an interface?

  3. Source: Original 175 #103 When would you choose an interface over an abstract class?

  4. Source: Original 175 #104 Can an abstract class implement an interface without implementing all methods?

  5. Source: Original 175 #105 Can an interface contain variables?

  6. Source: Original 175 #106 Can an interface have static methods?

  7. Source: Original 175 #107 Can an interface have default methods?

  8. Source: Original 175 #108 Can an interface have private methods?

  9. Source: Original 175 #109 Why were default methods introduced in Java 8?

  10. Source: Original 175 #110 Why are static methods allowed in interfaces?

  11. Source: Core 51 β€” copy 1 #41 Compare an Abstract Class and an Interface post-Java 8/9, taking default, static, and private interface methods into account.

  12. Source: Core 51 β€” copy 1 #42 Why can an interface variable never be declared as private, protected, or final?

  13. Source: Core 51 β€” copy 1 #43 When should a software engineer choose an Abstract Class over an Interface during architectural layout?

  14. Source: Core 51 β€” copy 2 #41 Compare an Abstract Class and an Interface post-Java 8/9, taking default, static, and private interface methods into account.

  15. Source: Core 51 β€” copy 2 #42 Why can an interface variable never be declared as private, protected, or final?

  16. Source: Core 51 β€” copy 2 #43 When should a software engineer choose an Abstract Class over an Interface during architectural layout?

ExpertΒΆ

  1. Source: Original 175 #111 Suppose two interfaces provide the same default method. What happens when a class implements both?

  2. Source: Original 175 #112 How can you resolve a default-method conflict between two interfaces?

  3. Source: Original 175 #113 Can an interface extend multiple interfaces? Explain with an example.

  4. Source: Original 175 #114 How does interface-based design help achieve loose coupling?

  5. Source: Original 175 #115 Why is programming to an interface considered good design?

  6. Source: Original 175 #161 You are designing a payment system supporting CreditCard, UPI, DebitCard, and NetBanking. How would you apply abstraction and polymorphism?

  7. Source: Original 175 #167 Two interfaces have the same default method. A class implements both. What happens, and how would you resolve it?

  8. Source: Original 175 #172 An order can be Created, Paid, Shipped, Delivered, or Cancelled. How would you model the behavior so that adding a new state doesn't result in hundreds of conditional statements?

  9. Source: Core 51 β€” copy 1 #44 How do Java 17+ Sealed Classes and Interfaces restrict hierarchy extensions, and how do they interact with switch pattern matching?

  10. Source: Core 51 β€” copy 1 #45 In a microservices architecture, how do interfaces serve as decoupled contracts between distinct application modules?

  11. Source: Core 51 β€” copy 2 #44 How do Java 17+ Sealed Classes and Interfaces restrict hierarchy extensions, and how do they interact with switch pattern matching?

  12. Source: Core 51 β€” copy 2 #45 In a microservices architecture, how do interfaces serve as decoupled contracts between distinct application modules?

  13. Source: Scenario 14 β€” copy 1 #6 The Enterprise SaaS Multi-Tenant RBAC Framework

  14. Scenario: A user management service requires Role-Based Access Control (RBAC). Admin, Manager, and Employee types have distinct data visibility and authorization rules.
  15. Question: How would you structure this using an Abstract Class to house the universal identity attributes (e.g., ID, Email) while enforcing Polymorphic Authorization Checks tailored to each role?

  16. Source: Scenario 14 β€” copy 1 #7 The Smart IoT Home Device Controller Matrix

  17. Scenario: You are writing code for a central IoT controller hub. It manages smart devices from different vendors (Philips Bulbs, Samsung ACs, Nest Cameras). None of these devices share an underlying codebase.
  18. Question: How do you use Interfaces as unified behavioral contracts to control actions like powerOn() and diagnose() seamlessly across incompatible hardware profiles?

  19. Source: Scenario 14 β€” copy 1 #13 The Food Delivery Order Tracking State Pattern

  20. Scenario: A food ordering app tracks live lifecycle milestones: OrderPlaced, KitchenPreparing, OutForDelivery, and Completed. The behavior of the cancel() method changes depending on the current status.
  21. Question: How can you combine Abstraction and encapsulation with the State Pattern to avoid monolithic, nested if-else blocks inside your cancel routine?

  22. Source: Scenario 14 β€” copy 2 #6 The Enterprise SaaS Multi-Tenant RBAC Framework

  23. Scenario: A user management service requires Role-Based Access Control (RBAC). Admin, Manager, and Employee types have distinct data visibility and authorization rules.
  24. Question: How would you structure this using an Abstract Class to house the universal identity attributes (e.g., ID, Email) while enforcing Polymorphic Authorization Checks tailored to each role?

  25. Source: Scenario 14 β€” copy 2 #7 The Smart IoT Home Device Controller Matrix

  26. Scenario: You are writing code for a central IoT controller hub. It manages smart devices from different vendors (Philips Bulbs, Samsung ACs, Nest Cameras). None of these devices share an underlying codebase.
  27. Question: How do you use Interfaces as unified behavioral contracts to control actions like powerOn() and diagnose() seamlessly across incompatible hardware profiles?

  28. Source: Scenario 14 β€” copy 2 #13 The Food Delivery Order Tracking State Pattern

  29. Scenario: A food ordering app tracks live lifecycle milestones: OrderPlaced, KitchenPreparing, OutForDelivery, and Completed. The behavior of the cancel() method changes depending on the current status.
  30. Question: How can you combine Abstraction and encapsulation with the State Pattern to avoid monolithic, nested if-else blocks inside your cancel routine?

7. OOP Tricky / Java Object ModelΒΆ

BeginnerΒΆ

  1. Source: Core 51 β€” copy 1 #46 Why is java.lang.Object positioned as the root superclass of every class hierarchy in Java?

  2. Source: Core 51 β€” copy 1 #47 What is the exact functional difference between the == operator and the .equals() method?

  3. Source: Core 51 β€” copy 2 #46 Why is java.lang.Object positioned as the root superclass of every class hierarchy in Java?

  4. Source: Core 51 β€” copy 2 #47 What is the exact functional difference between the == operator and the .equals() method?

IntermediateΒΆ

  1. Source: Core 51 β€” copy 1 #48 What is the formal contract established between the .hashCode() and .equals() methods in Java collections?

  2. Source: Core 51 β€” copy 1 #49 What is the difference between Shallow Cloning and Deep Cloning when overriding the clone() method?

  3. Source: Core 51 β€” copy 2 #48 What is the formal contract established between the .hashCode() and .equals() methods in Java collections?

  4. Source: Core 51 β€” copy 2 #49 What is the difference between Shallow Cloning and Deep Cloning when overriding the clone() method?

AdvancedΒΆ

  1. Source: Original 175 #126 Can a private method be overridden?

  2. Source: Original 175 #127 Can a static method be overridden?

  3. Source: Original 175 #128 Can a final method be overridden?

  4. Source: Original 175 #129 Can a constructor be inherited?

  5. Source: Original 175 #130 Can an abstract class have a constructor?

  6. Source: Original 175 #131 Can an interface have a constructor?

  7. Source: Original 175 #132 Can we instantiate an interface?

  8. Source: Original 175 #133 Can we instantiate an abstract class?

  9. Source: Original 175 #134 Can an abstract class contain a main() method?

  10. Source: Original 175 #135 Can a class be both final and abstract? Why?

  11. Source: Original 175 #136 Can a method be both abstract and final? Why?

  12. Source: Original 175 #137 Can an interface be declared final?

  13. Source: Original 175 #138 Can an interface contain concrete methods?

  14. Source: Original 175 #139 Can a child class have a more restrictive access modifier when overriding a method?

  15. Source: Original 175 #140 Can an overriding method throw a broader checked exception?

  16. Source: Original 175 #141 What is the difference between method hiding and method overriding?

  17. Source: Original 175 #142 What is the difference between this and super?

  18. Source: Original 175 #143 What is the difference between == and equals() in an OOP context?

  19. Source: Original 175 #144 Why must equals() and hashCode() generally be overridden together?

  20. Source: Original 175 #145 What problems can occur if you override equals() but not hashCode()?

ExpertΒΆ

  1. Source: Core 51 β€” copy 1 #50 Why is the utilization of the finalize() method heavily discouraged, deprecated, and slated for complete removal?

  2. Source: Core 51 β€” copy 1 #51 How do Java Records (introduced in Java 14/16) use built-in compilation mechanisms to automatically satisfy standard OOP identity contracts?

  3. Source: Core 51 β€” copy 2 #50 Why is the utilization of the finalize() method heavily discouraged, deprecated, and slated for complete removal?

  4. Source: Core 51 β€” copy 2 #51 How do Java Records (introduced in Java 14/16) use built-in compilation mechanisms to automatically satisfy standard OOP identity contracts?

  5. Source: Scenario 14 β€” copy 1 #9 The Financial Ledger Record Audit Integrity Violation

  6. Scenario: A financial platform processes accounting entry blocks that must remain strictly untampered once created. A bug in a utility routine changes a ledger entry post-reconciliation.
  7. Question: How do you use Java Records alongside the final keyword modifier to construct an audit trail that prevents post-creation state manipulation?

  8. Source: Scenario 14 β€” copy 2 #9 The Financial Ledger Record Audit Integrity Violation

  9. Scenario: A financial platform processes accounting entry blocks that must remain strictly untampered once created. A bug in a utility routine changes a ledger entry post-reconciliation.
  10. Question: How do you use Java Records alongside the final keyword modifier to construct an audit trail that prevents post-creation state manipulation?

8. SOLID, Coupling, Cohesion & OOP DesignΒΆ

ExpertΒΆ

  1. Source: Original 175 #146 Explain SOLID principles with Java examples.

  2. Source: Original 175 #147 What is the Single Responsibility Principle?

  3. Source: Original 175 #148 What is the Open/Closed Principle?

  4. Source: Original 175 #149 What is the Liskov Substitution Principle?

  5. Source: Original 175 #150 What is the Interface Segregation Principle?

  6. Source: Original 175 #151 What is the Dependency Inversion Principle?

  7. Source: Original 175 #152 How does polymorphism help implement the Open/Closed Principle?

  8. Source: Original 175 #153 How does dependency inversion reduce coupling?

  9. Source: Original 175 #154 What is tight coupling vs loose coupling?

  10. Source: Original 175 #155 What is high cohesion vs low cohesion?

  11. Source: Original 175 #156 How would you identify a God class?

  12. Source: Original 175 #157 How would you refactor a God class?

  13. Source: Original 175 #158 What is dependency injection from an OOP perspective?

  14. Source: Original 175 #159 How do design patterns relate to OOP principles?

  15. Source: Original 175 #160 Explain Factory, Strategy and Observer patterns using OOP concepts.

  16. Source: Original 175 #162 Your application supports Email, SMS, WhatsApp and Push notifications. How would you design it so that adding a new notification type doesn't require modifying existing business logic?

  17. Source: Original 175 #168 A developer changes an implementation inside a parent class and suddenly several child classes behave incorrectly. Which OOP/design problem might this indicate, and how would you fix it?

  18. Source: Original 175 #169 Your application generates PDF, Excel and CSV reports. How would you design the reporting architecture so a new report type can be added without modifying existing code?

  19. Source: Original 175 #171 Your application currently has logging code scattered across 100 classes. Which OOP/design principle would you apply to improve the design?

  20. Source: Original 175 #173 Your application uses a third-party payment API, but you don't want your business logic to depend directly on that vendor's classes. How would you design the system?

  21. Source: Original 175 #174 Your e-commerce application has different pricing algorithms for different customer types, countries and promotional campaigns. How would you design this without creating a huge conditional method?

  22. Source: Original 175 #175 You inherit a 5,000-line Java class containing database operations, business logic, validation, email sending and file generation. How would you refactor it using OOP principles?

  23. Source: Scenario 14 β€” copy 1 #2 The Corrupted Database Entity Modification Leak

  24. Scenario: A high-throughput database entity object is passed to multiple untrusted analytics modules. One module accidentally mutates the internal state of the entity, corrupting the production database.
  25. Question: How would you use defensive copying and true Encapsulation to make this object immune to external mutations?

  26. Source: Scenario 14 β€” copy 1 #4 The Logging Framework Upgrade Failure

  27. Scenario: An enterprise application relies heavily on third-party logging engines. During an upgrade, the logging vendor changes method signatures, breaking 500+ production classes.
  28. Question: How would you use the Adapter Pattern and Abstraction layers to isolate external code, ensuring that vendor modifications never compromise your inner application architecture?

  29. Source: Scenario 14 β€” copy 1 #10 The Distributed Microservices API Contract Drift

  30. Scenario: Team Alpha manages the inventory service, while Team Beta develops the frontend application. Team Alpha modifies the underlying core data types, causing immediate runtime crashes across Team Beta’s customer-facing views.
  31. Question: How do you apply Dependency Inversion to force both teams to depend strictly on immutable abstract schemas, eliminating code drift?

  32. Source: Scenario 14 β€” copy 2 #2 The Corrupted Database Entity Modification Leak

  33. Scenario: A high-throughput database entity object is passed to multiple untrusted analytics modules. One module accidentally mutates the internal state of the entity, corrupting the production database.
  34. Question: How would you use defensive copying and true Encapsulation to make this object immune to external mutations?

  35. Source: Scenario 14 β€” copy 2 #4 The Logging Framework Upgrade Failure

  36. Scenario: An enterprise application relies heavily on third-party logging engines. During an upgrade, the logging vendor changes method signatures, breaking 500+ production classes.
  37. Question: How would you use the Adapter Pattern and Abstraction layers to isolate external code, ensuring that vendor modifications never compromise your inner application architecture?

  38. Source: Scenario 14 β€” copy 2 #10 The Distributed Microservices API Contract Drift

  39. Scenario: Team Alpha manages the inventory service, while Team Beta develops the frontend application. Team Alpha modifies the underlying core data types, causing immediate runtime crashes across Team Beta’s customer-facing views.
  40. Question: How do you apply Dependency Inversion to force both teams to depend strictly on immutable abstract schemas, eliminating code drift?

Consolidation NotesΒΆ

  • Total question entries retained: 305.
  • The source contains the original 175-question set plus a 51-question core set and a 14-scenario set repeated a second time.
  • The repeated sets were intentionally retained because the instruction was not to delete any questions.
  • Only the grouping, ordering, and source labels were changed; question wording was not rewritten.