{"id":19114,"date":"2026-02-19T10:00:04","date_gmt":"2026-02-19T04:30:04","guid":{"rendered":"https:\/\/www.placementpreparation.io\/blog\/?p=19114"},"modified":"2026-03-06T13:26:47","modified_gmt":"2026-03-06T07:56:47","slug":"oops-interview-questions","status":"publish","type":"post","link":"https:\/\/www.placementpreparation.io\/blog\/oops-interview-questions\/","title":{"rendered":"OOPS Interview Questions and Answers"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Preparing for a technical interview? <a href=\"https:\/\/www.guvi.in\/courses\/programming\/object-oriented-programming\/?utm_source=placement_preparation&amp;utm_medium=blog_cta&amp;utm_campaign=oops_interview_questions\" target=\"_blank\" rel=\"noopener\">OOPS is a core topic<\/a> tested across languages like Java, C++, and Python.<\/p><p>Interviewers assess your understanding of concepts such as encapsulation, abstraction, inheritance, and polymorphism, along with their practical implementation.<\/p><p>This guide on OOPS interview questions and answers provides structured, interview-focused questions categorized by difficulty level to help you revise concepts quickly and confidently.<\/p><hr><h2>OOPS Interview Questions for Freshers<\/h2><hr><h3>1. Explain the four main principles of Object-Oriented Programming with examples.<\/h3><p><a href=\"https:\/\/www.guvi.in\/hub\/javascript\/oops-in-javascript\/?utm_source=placement_preparation&amp;utm_medium=blog_cta&amp;utm_campaign=oops_interview_questions\" target=\"_blank\" rel=\"noopener\">Object-Oriented Programming<\/a> is based on four core principles that help structure and manage software effectively.<\/p><p><strong>Encapsulation &ndash;<\/strong> Bundling data and methods inside a class and restricting direct access to internal variables.<\/p><ul>\n<li><strong>Example:<\/strong> A BankAccount class keeps balance private and provides deposit() and withdraw() methods.<\/li>\n<\/ul><p><strong>Abstraction &ndash;<\/strong> Hiding implementation details and showing only essential functionality.<\/p><ul>\n<li>Example: A Car class provides a start() method without exposing engine logic.<\/li>\n<\/ul><p><strong>Inheritance &ndash;<\/strong> Allowing one class to acquire properties and behavior of another class.<\/p><ul>\n<li>Example: SavingsAccount extends BankAccount.<\/li>\n<\/ul><p><strong>Polymorphism &ndash;<\/strong> Allowing objects to take multiple forms.<\/p><ul>\n<li>Example: A Shape class with an overridden draw() method in Circle and Rectangle.<\/li>\n<\/ul><p><img decoding=\"async\" class=\"alignnone size-full wp-image-19507\" src=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/oops-principles.webp\" alt=\"oops principles\" width=\"1200\" height=\"800\" srcset=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/oops-principles.webp 1200w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/oops-principles-300x200.webp 300w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/oops-principles-1024x683.webp 1024w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/oops-principles-768x512.webp 768w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/oops-principles-150x100.webp 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\"><\/p><h3>2. Differentiate between class and object.<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Class<\/b><\/td>\n<td><b>Object<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Definition<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Blueprint for creating objects<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Instance of a class<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Memory Allocation<\/span><\/td>\n<td><span style=\"font-weight: 400;\">No memory allocated<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Memory allocated at runtime<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Example<\/span><\/td>\n<td><span style=\"font-weight: 400;\">class Car {}<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Car c = new Car();<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Purpose<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Defines properties and methods<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Uses defined properties and methods<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>A class defines structure, while an object represents a real entity created from that structure.<\/p><h3>3. How does encapsulation improve code security and maintainability?<\/h3><p>Encapsulation protects data by restricting direct access and exposing it through controlled methods.<\/p><p><strong>It improves security by:<\/strong><\/p><ul>\n<li>Preventing unauthorized modification of variables.<\/li>\n<li>Allowing validation inside setter methods.<\/li>\n<\/ul><p><strong>It improves maintainability by:<\/strong><\/p><ul>\n<li>Keeping internal implementation hidden.<\/li>\n<li>Allowing internal changes without affecting external code.<\/li>\n<li>Reducing tight coupling between components.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Account {<br>\nprivate double balance;<br>\npublic void deposit(double amount) {<br>\nif (amount &gt; 0) balance += amount;<br>\n}<br>\n}<\/p>\n<\/div><\/div><h3>4. Compare abstraction and encapsulation.<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Abstraction<\/b><\/td>\n<td><b>Encapsulation<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Focus<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Hides implementation details<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Hides internal data<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Implementation<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Abstract classes, interfaces<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Access modifiers<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Purpose<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Simplifies complexity<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Protects data integrity<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Example<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Interface with method definitions<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Private variables with getters\/setters<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Abstraction focuses on what an object does, while encapsulation focuses on how data is protected.<\/p><h3>5. What is inheritance? Explain different types of inheritance.<\/h3><p>Inheritance allows a class to acquire properties and methods from another class, promoting code reuse.<\/p><p><strong>Common types of inheritance:<\/strong><\/p><ul>\n<li><strong>Single Inheritance &ndash;<\/strong> One child class inherits from one parent class.<\/li>\n<li><strong>Multilevel Inheritance &ndash;<\/strong> A class inherits from a class which itself inherits from another class.<\/li>\n<li><strong>Hierarchical Inheritance &ndash;<\/strong> Multiple child classes inherit from a single parent.<\/li>\n<li><strong>Multiple Inheritance &ndash;<\/strong> A class inherits from more than one parent (supported in C++, achieved using <a href=\"https:\/\/www.guvi.in\/blog\/oops-concepts-in-java-4-basic-concepts\/\" target=\"_blank\" rel=\"noopener\">interfaces in Java<\/a>).<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Animal { void eat() {} }<br>\nclass Dog extends Animal { void bark() {} }<\/p>\n<\/div><\/div><h3>6. What is polymorphism? Differentiate between compile-time and runtime polymorphism.<\/h3><p>Polymorphism allows the same method name to behave differently based on context.<\/p><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Compile-Time Polymorphism<\/b><\/td>\n<td><b>Runtime Polymorphism<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Also Known As<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Method Overloading<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Method Overriding<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Binding Time<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Compile time<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Runtime<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Decision Based On<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Method signature<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Object type<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Example<\/span><\/td>\n<td><span style=\"font-weight: 400;\">add(int, int)<\/span><span style=\"font-weight: 400;\"> and <\/span><span style=\"font-weight: 400;\">add(double, double)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Overridden method in subclass<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Compile-time polymorphism is resolved during compilation, while runtime polymorphism is resolved during execution using dynamic binding.<\/p><p><a href=\"https:\/\/www.guvi.in\/mlp\/fsd-student-program-wp?utm_source=placement_preparation&amp;utm_medium=blog_banner&amp;utm_campaign=oops_interview_questions_horizontal\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"alignnone wp-image-15830 size-full\" src=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/06\/fsd-image-web-horizontal.webp\" alt=\"fsd zen lite free trial banner horizontal\" width=\"1920\" height=\"507\" srcset=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/06\/fsd-image-web-horizontal.webp 1920w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/06\/fsd-image-web-horizontal-300x79.webp 300w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/06\/fsd-image-web-horizontal-1024x270.webp 1024w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/06\/fsd-image-web-horizontal-768x203.webp 768w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/06\/fsd-image-web-horizontal-1536x406.webp 1536w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/06\/fsd-image-web-horizontal-150x40.webp 150w\" sizes=\"(max-width: 1920px) 100vw, 1920px\"><\/a><\/p><h3>7. How does method overloading differ from method overriding?<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Method Overloading<\/b><\/td>\n<td><b>Method Overriding<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Definition<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Same method name, different parameters<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Redefining parent method in child<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Occurs In<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Same class<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Parent and child class<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Binding<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Compile time<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Runtime<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Return Type<\/span><\/td>\n<td><span style=\"font-weight: 400;\">May vary (with parameter change)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Must match parent method<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Access Modifier<\/span><\/td>\n<td><span style=\"font-weight: 400;\">No strict restriction<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Cannot reduce visibility<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Overloading increases method flexibility, while overriding enables runtime polymorphism.<\/p><h3>8. What is a constructor? Can a constructor be overloaded?<\/h3><p>A constructor is a special method used to initialize objects when they are created. It has the same name as the class and does not have a return type.<\/p><p>Yes, constructors can be overloaded by defining multiple constructors with different parameter lists.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Student {<br>\nStudent() {}<br>\nStudent(String name) {}<br>\n}<\/p>\n<\/div><\/div><p>Constructor overloading allows flexible object initialization.<\/p><h3>9. What is the difference between an abstract class and an interface?<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Abstract Class<\/b><\/td>\n<td><b>Interface<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Method Type<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Can have abstract and concrete methods<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Typically abstract methods<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Variables<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Can have instance variables<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Only constants (by default)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Multiple Inheritance<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Not supported<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Supported<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Constructor<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Can have constructor<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Cannot have constructor<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Use Case<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Shared base class<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Defining capability contract<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Abstract classes are used when classes share common behavior, while interfaces define contracts that multiple classes can implement.<\/p><h3>10. Why is data hiding important in OOPS?<\/h3><p>Data hiding restricts direct access to internal object data using access modifiers like private and protected.<\/p><p><strong>Its importance includes:<\/strong><\/p><ul>\n<li>Protects sensitive information.<\/li>\n<li>Prevents accidental modification.<\/li>\n<li>Ensures controlled access through methods.<\/li>\n<li>Improves modularity and maintainability.<\/li>\n<li>Supports secure and robust design.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong> Keeping password fields private in a User class ensures they cannot be modified directly from outside the class.<\/p>\n<\/div><\/div><h3>11. Write a simple class to represent a BankAccount with deposit and withdraw methods.<\/h3><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>class BankAccount {<br>\nprivate double balance;<\/p>\n<p>public BankAccount(double initialBalance) {<br>\nbalance = initialBalance;<br>\n}<\/p>\n<p>public void deposit(double amount) {<br>\nif (amount &gt; 0) {<br>\nbalance += amount;<br>\n}<br>\n}<\/p>\n<p>public void withdraw(double amount) {<br>\nif (amount &gt; 0 &amp;&amp; amount &lt;= balance) {<br>\nbalance -= amount;<br>\n}<br>\n}<\/p>\n<p>public double getBalance() {<br>\nreturn balance;<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>This example demonstrates encapsulation by keeping balance private and allowing controlled access through public methods.<\/p><h3>12. What will be the output of a program where a subclass overrides a method of its parent class?<\/h3><p>When a subclass overrides a method, runtime polymorphism ensures that the child class method is executed if the object is of the child type.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Animal {<br>\nvoid sound() {<br>\nSystem.out.println(&ldquo;Animal makes a sound&rdquo;);<br>\n}<br>\n}<\/p>\n<p>class Dog extends Animal {<br>\nvoid sound() {<br>\nSystem.out.println(&ldquo;Dog barks&rdquo;);<br>\n}<br>\n}<\/p>\n<p>public class Test {<br>\npublic static void main(String[] args) {<br>\nAnimal obj = new Dog();<br>\nobj.sound();<br>\n}<br>\n}<\/p>\n<\/div><\/div><p><strong>Output:<\/strong><\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>Dog barks<\/p>\n<p>Even though the reference type is Animal, the overridden method in Dog is executed because of dynamic binding.<\/p>\n<\/div><\/div><h3>13. Write a program to demonstrate method overloading.<\/h3><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>class Calculator {<\/p>\n<p>int add(int a, int b) {<br>\nreturn a + b;<br>\n}<\/p>\n<p>double add(double a, double b) {<br>\nreturn a + b;<br>\n}<\/p>\n<p>public static void main(String[] args) {<br>\nCalculator c = new Calculator();<br>\nSystem.out.println(c.add(5, 3));<br>\nSystem.out.println(c.add(5.5, 3.2));<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>Method overloading allows multiple methods with the same name but different parameter types. The compiler decides which method to call based on arguments.<\/p><h3>14. Write a simple example to demonstrate runtime polymorphism using inheritance.<\/h3><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>class Shape {<br>\nvoid draw() {<br>\nSystem.out.println(&ldquo;Drawing shape&rdquo;);<br>\n}<br>\n}<\/p>\n<p>class Circle extends Shape {<br>\nvoid draw() {<br>\nSystem.out.println(&ldquo;Drawing circle&rdquo;);<br>\n}<br>\n}<\/p>\n<p>public class Demo {<br>\npublic static void main(String[] args) {<br>\nShape s = new Circle();<br>\ns.draw();<br>\n}<br>\n}<\/p>\n<\/div><\/div><p><strong>Output:<\/strong><\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>Drawing circle<\/p>\n<p>Here, the method call is resolved at runtime based on the object type, demonstrating runtime polymorphism.<\/p>\n<\/div><\/div><h3>15. How do access modifiers affect inheritance?<\/h3><p>Access modifiers determine how members of a class are accessible in subclasses.<\/p><ul>\n<li><strong>public &ndash;<\/strong> Accessible everywhere, including subclasses.<\/li>\n<li><strong>protected &ndash;<\/strong> Accessible within the same package and in subclasses.<\/li>\n<li><strong>default (no modifier) &ndash;<\/strong> Accessible only within the same package.<\/li>\n<li><strong>private &ndash;<\/strong> Not accessible directly in subclasses.<\/li>\n<\/ul><p>Private members are not inherited directly but can be accessed through public or protected methods.<\/p><p><img decoding=\"async\" class=\"alignnone size-full wp-image-19506\" src=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/access-specifiers-in-java.webp\" alt=\"access specifiers in java\" width=\"1200\" height=\"800\" srcset=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/access-specifiers-in-java.webp 1200w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/access-specifiers-in-java-300x200.webp 300w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/access-specifiers-in-java-1024x683.webp 1024w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/access-specifiers-in-java-768x512.webp 768w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/access-specifiers-in-java-150x100.webp 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\"><\/p><h3>16. What is the difference between stack memory and heap memory in OOPS?<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Stack Memory<\/b><\/td>\n<td><b>Heap Memory<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Stores<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Method calls, local variables<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Objects and instance variables<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Allocation<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Automatic<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Manual (via new keyword)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Lifetime<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ends when method exits<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Until object is garbage collected<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Speed<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Faster access<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Slower compared to stack<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Memory Size<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Limited<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Larger than stack<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Stack memory manages execution flow, while heap memory stores objects created at runtime.<\/p><h3>17. What happens when an object is created in memory?<\/h3><p>When an object is created using the new keyword:<\/p><ul>\n<li>Memory is allocated in the heap.<\/li>\n<li>Instance variables are initialized (default or assigned values).<\/li>\n<li>Constructor is executed.<\/li>\n<li>A reference variable in stack memory points to the heap object.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>Student s = new Student();<\/p>\n<p>Here, s is stored in stack memory and refers to the object stored in heap memory.<\/p>\n<\/div><\/div><h3>18. What is the role of the &ldquo;this&rdquo; keyword?<\/h3><p>The this keyword refers to the current object of a class.<\/p><p><strong>It is used to:<\/strong><\/p><ul>\n<li>Differentiate instance variables from local variables.<\/li>\n<li>Call current class constructor.<\/li>\n<li>Pass current object as a parameter.<\/li>\n<li>Return the current instance.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Student {<br>\nint age;<\/p>\n<p>Student(int age) {<br>\nthis.age = age;<br>\n}<br>\n}<\/p>\n<p>Here, this.age refers to the instance variable.<\/p>\n<\/div><\/div><h3>19. Can constructors be inherited? Why or why not?<\/h3><p>Constructors are not inherited because they are used to initialize the specific class in which they are defined.<\/p><p>However, a subclass can call a parent constructor using super().<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Parent {<br>\nParent() {<br>\nSystem.out.println(&ldquo;Parent constructor&rdquo;);<br>\n}<br>\n}<\/p>\n<p>class Child extends Parent {<br>\nChild() {<br>\nsuper();<br>\nSystem.out.println(&ldquo;Child constructor&rdquo;);<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>Constructors ensure proper initialization hierarchy but are not inherited like methods.<\/p><h3>20. Why does OOPS promote code reusability?<\/h3><p>OOPS promotes code reusability through inheritance, composition, and modular design.<\/p><ul>\n<li>Inheritance allows reuse of existing class functionality.<\/li>\n<li>Polymorphism enables flexible and extensible design.<\/li>\n<li>Encapsulation ensures modular components.<\/li>\n<li>Design patterns encourage reusable architecture.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong> A base Vehicle class can be extended by Car, Bike, and Truck, reusing common logic without rewriting code.<\/p>\n<\/div><\/div><hr><h2>OOPS Interview Questions for Intermediate<\/h2><hr><h3>1. Explain the concept of dynamic binding with an example.<\/h3><p>Dynamic binding, also known as late binding, refers to resolving method calls at runtime instead of compile time. The method that gets executed depends on the object type, not the reference type.<\/p><p>It enables runtime polymorphism.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Animal {<br>\nvoid sound() {<br>\nSystem.out.println(&ldquo;Animal sound&rdquo;);<br>\n}<br>\n}<\/p>\n<p>class Cat extends Animal {<br>\nvoid sound() {<br>\nSystem.out.println(&ldquo;Cat meows&rdquo;);<br>\n}<br>\n}<\/p>\n<p>public class Test {<br>\npublic static void main(String[] args) {<br>\nAnimal obj = new Cat();<br>\nobj.sound();<br>\n}<br>\n}<\/p>\n<\/div><\/div><p><strong>Output:<\/strong><\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>Cat meows<\/p>\n<p>Even though the reference is of type Animal, the method in Cat is executed at runtime.<\/p>\n<\/div><\/div><p><img decoding=\"async\" class=\"alignnone size-full wp-image-19505\" src=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-the-concept-of-dynamic-binding-with-an-example.webp\" alt=\"explain the concept of dynamic binding with an example.\" width=\"1200\" height=\"800\" srcset=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-the-concept-of-dynamic-binding-with-an-example.webp 1200w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-the-concept-of-dynamic-binding-with-an-example-300x200.webp 300w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-the-concept-of-dynamic-binding-with-an-example-1024x683.webp 1024w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-the-concept-of-dynamic-binding-with-an-example-768x512.webp 768w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-the-concept-of-dynamic-binding-with-an-example-150x100.webp 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\"><\/p><h3>2. How does method overriding achieve runtime polymorphism?<\/h3><p>Method overriding allows a subclass to provide a specific implementation of a method already defined in its parent class.<\/p><p>When a parent class reference points to a child class object, the overridden method in the child class is executed during runtime.<\/p><p>Key conditions for overriding:<\/p><p>Same method name<br>\nSame parameters<br>\nSame or covariant return type<br>\nCannot reduce access level<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Vehicle {<br>\nvoid run() {<br>\nSystem.out.println(&ldquo;Vehicle running&rdquo;);<br>\n}<br>\n}<\/p>\n<p>class Car extends Vehicle {<br>\nvoid run() {<br>\nSystem.out.println(&ldquo;Car running&rdquo;);<br>\n}<br>\n}<br>\nAt runtime, the child class method is selected based on the object type.<\/p>\n<\/div><\/div><h3>3. Compare abstract class and interface with use cases.<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Abstract Class<\/b><\/td>\n<td><b>Interface<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Method Types<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Abstract and concrete methods<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Abstract methods (default and static allowed in modern Java)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Variables<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Instance variables allowed<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Only constants<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Constructors<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Can have constructors<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Cannot have constructors<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Multiple Inheritance<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Not supported<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Supported<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Use Case<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Common base with shared behavior<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Define capability or contract<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Use abstract classes when classes share common implementation. Use interfaces when defining behavior that multiple unrelated classes must implement.<\/p><h3>4. What is multiple inheritance? How is it handled in Java?<\/h3><p>Multiple inheritance allows a class to inherit from more than one parent class.<\/p><p>Java does not support multiple inheritance with classes to avoid ambiguity and complexity. Instead, Java allows multiple inheritance through interfaces.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>interface A {<br>\nvoid show();<br>\n}<\/p>\n<p>interface B {<br>\nvoid display();<br>\n}<\/p>\n<p>class C implements A, B {<br>\npublic void show() {}<br>\npublic void display() {}<br>\n}<\/p>\n<\/div><\/div><p>Here, class C implements multiple interfaces, achieving multiple inheritance behavior safely.<\/p><h3>5. Explain the diamond problem and its solution.<\/h3><p>The diamond problem occurs in multiple inheritance when two parent classes inherit from the same base class, and a child class inherits from both, causing ambiguity.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example structure:<\/strong><\/p>\n<p>Class A<br>\nClass B extends A<br>\nClass C extends A<br>\nClass D extends B and C<br>\nIf D calls a method defined in A, it becomes unclear whether B&rsquo;s or C&rsquo;s version should be used.<\/p>\n<\/div><\/div><p>Java avoids this problem by:<\/p><ul>\n<li>Not allowing multiple inheritance with classes.<\/li>\n<li>Allowing interfaces with explicit method implementation if ambiguity occurs.<\/li>\n<\/ul><p>Thus, ambiguity is resolved by forcing the child class to override conflicting methods.<\/p><h3>6. What are virtual functions and why are they important?<\/h3><p>Virtual functions are methods whose execution is determined at runtime based on the object type.<\/p><p>In C++, functions are made virtual using the virtual keyword. In Java, all non-static methods are virtual by default.<\/p><p><strong>Importance:<\/strong><\/p><ul>\n<li>Enable runtime polymorphism<\/li>\n<li>Allow dynamic method dispatch<\/li>\n<li>Improve extensibility of applications<\/li>\n<li>Support flexible design<\/li>\n<\/ul><p>Without virtual functions, method calls would be resolved at compile time, limiting polymorphism.<\/p><h3>7. What is composition? How is it different from inheritance?<\/h3><p>Composition is a design technique where one class contains an instance of another class to reuse functionality.<\/p><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Composition<\/b><\/td>\n<td><b>Inheritance<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Relationship<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Has-a<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Is-a<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Coupling<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Looser<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Tighter<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Flexibility<\/span><\/td>\n<td><span style=\"font-weight: 400;\">High<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Limited<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Code Reuse<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Through object references<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Through subclassing<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Example<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Car has Engine<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Dog is Animal<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Composition allows behavior reuse without creating rigid class hierarchies.<\/p><h3>8. When would you prefer composition over inheritance?<\/h3><p>Composition is preferred when:<\/p><ul>\n<li>Relationship is &ldquo;has-a&rdquo; rather than &ldquo;is-a&rdquo;<\/li>\n<li>Flexibility is required<\/li>\n<li>Behavior may change at runtime<\/li>\n<li>Avoiding deep inheritance hierarchies<\/li>\n<li>Preventing tight coupling between classes<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong> A Car should contain an Engine object instead of inheriting from Engine.<\/p>\n<\/div><\/div><p>Composition improves maintainability and scalability.<\/p><h3>9. Explain the concept of object cloning.<\/h3><p>Object cloning creates a copy of an existing object.<\/p><p>In Java, cloning is done using the Cloneable interface and overriding the clone() method.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Student implements Cloneable {<br>\nint id;<\/p>\n<p>protected Object clone() throws CloneNotSupportedException {<br>\nreturn super.clone();<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>Cloning creates a new object with the same values as the original object. It is useful when object creation is expensive or when duplicating state is required.<\/p><h3>10. What is the difference between shallow copy and deep copy?<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Shallow Copy<\/b><\/td>\n<td><b>Deep Copy<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Object References<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Copied as reference<\/span><\/td>\n<td><span style=\"font-weight: 400;\">New object created<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Nested Objects<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Shared between copies<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Independently copied<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Performance<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Faster<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Slower<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Memory Usage<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Less<\/span><\/td>\n<td><span style=\"font-weight: 400;\">More<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Risk<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Changes affect both objects<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Independent objects<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Shallow copy duplicates only primitive values and references, while deep copy duplicates the entire object graph.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong> If an object contains another object as a field, shallow copy shares it; deep copy creates a new copy of that internal object.<\/p>\n<\/div><\/div><h3>11. Write a class hierarchy for Shape and implement area calculation using polymorphism.<\/h3><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>abstract class Shape {<br>\nabstract double area();<br>\n}<\/p>\n<p>class Circle extends Shape {<br>\nprivate double radius;<\/p>\n<p>Circle(double radius) {<br>\nthis.radius = radius;<br>\n}<\/p>\n<p>double area() {<br>\nreturn Math.PI * radius * radius;<br>\n}<br>\n}<\/p>\n<p>class Rectangle extends Shape {<br>\nprivate double length, width;<\/p>\n<p>Rectangle(double length, double width) {<br>\nthis.length = length;<br>\nthis.width = width;<br>\n}<\/p>\n<p>double area() {<br>\nreturn length * width;<br>\n}<br>\n}<\/p>\n<p>public class TestShape {<br>\npublic static void main(String[] args) {<br>\nShape s1 = new Circle(5);<br>\nShape s2 = new Rectangle(4, 6);<\/p>\n<p>System.out.println(s1.area());<br>\nSystem.out.println(s2.area());<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>A single reference type Shape can call area() for different objects, and the correct implementation is chosen at runtime.<\/p><h3>12. Design a class that demonstrates encapsulation with private variables and getter\/setter methods.<\/h3><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>class Employee {<br>\nprivate int id;<br>\nprivate String name;<\/p>\n<p>public Employee(int id, String name) {<br>\nthis.id = id;<br>\nthis.name = name;<br>\n}<\/p>\n<p>public int getId() {<br>\nreturn id;<br>\n}<\/p>\n<p>public void setId(int id) {<br>\nif (id &gt; 0) {<br>\nthis.id = id;<br>\n}<br>\n}<\/p>\n<p>public String getName() {<br>\nreturn name;<br>\n}<\/p>\n<p>public void setName(String name) {<br>\nif (name != null &amp;&amp; !name.isEmpty()) {<br>\nthis.name = name;<br>\n}<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>Encapsulation protects internal data and allows validation through setters before updating values.<\/p><h3>13. Write pseudocode for implementing an interface in a payment system.<\/h3><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>Interface PaymentMethod:<br>\nMethod pay(amount)<\/p>\n<p>Class UpiPayment implements PaymentMethod:<br>\nMethod pay(amount):<br>\nValidate UPI ID<br>\nDeduct amount<br>\nReturn success message<\/p>\n<p>Class CardPayment implements PaymentMethod:<br>\nMethod pay(amount):<br>\nValidate card number and OTP<br>\nDeduct amount<br>\nReturn success message<\/p>\n<p>Main:<br>\nPaymentMethod pm = new UpiPayment()<br>\npm.pay(500)<\/p>\n<p>pm = new CardPayment()<br>\npm.pay(1000)<\/p>\n<\/div><\/div><p>This design supports adding new payment types without changing the existing payment flow.<\/p><h3>14. How would you prevent method overriding in a subclass?<\/h3><p>To prevent method overriding:<\/p><ul>\n<li>Declare the method as final so subclasses cannot override it.<\/li>\n<li>Declare the class as final so it cannot be inherited.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Parent {<br>\nfinal void show() {<br>\nSystem.out.println(&ldquo;Cannot override&rdquo;);<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>If the method is final, any attempt to override it in a subclass will cause a compile-time error.<\/p><h3>15. Write a small program to demonstrate constructor chaining.<\/h3><p>Constructor chaining means calling one constructor from another constructor in the same class or calling a parent constructor.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>class Parent {<br>\nParent() {<br>\nSystem.out.println(&ldquo;Parent constructor&rdquo;);<br>\n}<br>\n}<\/p>\n<p>class Child extends Parent {<br>\nChild() {<br>\nsuper();<br>\nSystem.out.println(&ldquo;Child constructor&rdquo;);<br>\n}<br>\n}<\/p>\n<p>public class Test {<br>\npublic static void main(String[] args) {<br>\nChild c = new Child();<br>\n}<br>\n}<\/p>\n<\/div><\/div><p><strong>Output:<\/strong><\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>Parent constructor<br>\nChild constructor<\/p>\n<p>The parent constructor executes first, then the child constructor.<\/p>\n<\/div><\/div><h3>16. What are SOLID principles in OOPS?<\/h3><p>SOLID is a set of design principles that helps build maintainable and scalable object-oriented systems.<\/p><ul>\n<li>S Single Responsibility Principle<\/li>\n<li>O Open\/Closed Principle<\/li>\n<li>L Liskov Substitution Principle<\/li>\n<li>I Interface Segregation Principle<\/li>\n<li>D Dependency Inversion Principle<\/li>\n<\/ul><p>These principles reduce coupling, improve readability, and make systems easier to extend.<\/p><p><img decoding=\"async\" class=\"alignnone size-full wp-image-19504\" src=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/solid-principles-in-oops.webp\" alt=\"solid principles in oops\" width=\"1200\" height=\"800\" srcset=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/solid-principles-in-oops.webp 1200w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/solid-principles-in-oops-300x200.webp 300w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/solid-principles-in-oops-1024x683.webp 1024w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/solid-principles-in-oops-768x512.webp 768w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/solid-principles-in-oops-150x100.webp 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\"><\/p><h3>17. Explain the Single Responsibility Principle with example.<\/h3><p>Single Responsibility Principle states that a class should have only one reason to change, meaning it should handle only one responsibility.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>Bad design:<\/p>\n<ul>\n<li>Invoice class handles invoice calculation and also printing.<\/li>\n<\/ul>\n<p>Better design:<\/p>\n<ul>\n<li>Invoice class calculates totals.<\/li>\n<li>InvoicePrinter class prints invoices.<\/li>\n<\/ul>\n<p>This separation improves maintainability because changes in printing logic do not affect invoice calculation.<\/p>\n<\/div><\/div><h3>18. What is tight coupling and loose coupling?<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Tight Coupling<\/b><\/td>\n<td><b>Loose Coupling<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Dependency<\/span><\/td>\n<td><span style=\"font-weight: 400;\">High<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Low<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Flexibility<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Low<\/span><\/td>\n<td><span style=\"font-weight: 400;\">High<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Change Impact<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Changes affect multiple classes<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Changes are isolated<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Testing<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Harder to test<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Easier to test<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Example<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Class directly creates dependency<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Dependency injected via interface<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Loose coupling is preferred because it improves scalability, testing, and maintainability.<\/p><h3>19. How does dependency injection relate to OOPS?<\/h3><p>Dependency Injection is a technique where an object receives its dependencies from outside rather than creating them internally.<\/p><p><strong>It supports OOPS by:<\/strong><\/p><ul>\n<li>Promoting loose coupling<\/li>\n<li>Improving testability<\/li>\n<li>Supporting interface-based design<\/li>\n<li>Aligning with Dependency Inversion Principle<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong> Instead of Car creating an Engine, the Engine is passed into the Car constructor.<\/p>\n<p>This makes the class flexible and easier to modify or test.<\/p>\n<\/div><\/div><h3>20. How do design patterns relate to object-oriented programming?<\/h3><p>Design patterns are reusable solutions to common design problems in object-oriented systems.<\/p><p><strong>They help by:<\/strong><\/p><ul>\n<li>Improving code structure and readability<\/li>\n<li>Promoting best practices like loose coupling<\/li>\n<li>Supporting scalability and maintainability<\/li>\n<li>Providing proven architectural approaches<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<ul>\n<li>Factory Pattern creates objects without exposing creation logic.<\/li>\n<li>Strategy Pattern allows changing behavior dynamically.<\/li>\n<\/ul>\n<p>Design patterns strengthen OOPS by providing standard ways to apply OOPS principles effectively.<\/p>\n<\/div><\/div><hr><h2>OOPS Interview Questions for Experienced<\/h2><hr><h3>1. How do SOLID principles improve large-scale application design?<\/h3><p>SOLID principles improve scalability, maintainability, and flexibility in enterprise systems by reducing tight coupling and promoting clear separation of concerns.<\/p><ul>\n<li>Single Responsibility ensures each class has one reason to change, reducing complexity.<\/li>\n<li>Open\/Closed allows adding new features without modifying existing code.<\/li>\n<li>Liskov Substitution ensures subclasses behave consistently with parent classes.<\/li>\n<li>Interface Segregation prevents large, unused interfaces.<\/li>\n<li>Dependency Inversion reduces direct dependency on concrete implementations.<\/li>\n<\/ul><p>In large-scale systems, these principles make modules independent, testable, and easier to extend without breaking existing functionality.<\/p><h3>2. Compare inheritance, composition, and aggregation.<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Inheritance<\/b><\/td>\n<td><b>Composition<\/b><\/td>\n<td><b>Aggregation<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Relationship<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Is-a<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Has-a (strong ownership)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Has-a (weak ownership)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Coupling<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Tight<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Moderate<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Looser<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Lifecycle Dependency<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Child depends on parent<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Part depends on whole<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Independent lifecycle<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Flexibility<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Less flexible<\/span><\/td>\n<td><span style=\"font-weight: 400;\">More flexible<\/span><\/td>\n<td><span style=\"font-weight: 400;\">More flexible<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Example<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Car is Vehicle<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Car has Engine<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Team has Players<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Inheritance promotes code reuse through hierarchy. Composition embeds objects strongly. Aggregation represents association where objects can exist independently.<\/p><h3>3. How would you refactor a tightly coupled legacy system using OOPS principles?<\/h3><p>Refactoring a tightly coupled system involves:<\/p><ul>\n<li>Identifying classes with multiple responsibilities.<\/li>\n<li>Applying Single Responsibility Principle.<\/li>\n<li>Introducing interfaces to abstract dependencies.<\/li>\n<li>Using dependency injection instead of direct object creation.<\/li>\n<li>Replacing inheritance misuse with composition.<\/li>\n<li>Breaking large classes into modular components.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong> Replace direct instantiation:<\/p>\n<p>Report report = new PDFReport();<\/p>\n<p><strong>With interface-based injection:<\/strong><\/p>\n<p>Report report = new PDFReport();<br>\ngenerate(report);<\/p>\n<p>This reduces dependency and improves maintainability.<\/p>\n<\/div><\/div><h3>4. Explain Liskov Substitution Principle with a real-world coding example.<\/h3><p>Liskov Substitution Principle states that a subclass should be replaceable with its parent class without altering system behavior.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Incorrect example:<\/strong><\/p>\n<p>class Bird {<br>\nvoid fly() {}<br>\n}<\/p>\n<p>class Ostrich extends Bird {<br>\nvoid fly() {<br>\nthrow new UnsupportedOperationException();<br>\n}<br>\n}<\/p>\n<p>This violates LSP because Ostrich cannot fly.<\/p>\n<\/div><\/div><p><strong>Correct approach:<\/strong><\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>class Bird {}<\/p>\n<p>class FlyingBird extends Bird {<br>\nvoid fly() {}<br>\n}<\/p>\n<p>class Ostrich extends Bird {}<br>\nclass Sparrow extends FlyingBird {}<\/p>\n<p>Now subclasses behave consistently without breaking expectations.<\/p>\n<\/div><\/div><p><img decoding=\"async\" class=\"alignnone size-full wp-image-19503\" src=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-liskov-substitution-principle-with-a-real-world-coding-example.webp\" alt=\"explain liskov substitution principle with a real world coding example\" width=\"1200\" height=\"800\" srcset=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-liskov-substitution-principle-with-a-real-world-coding-example.webp 1200w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-liskov-substitution-principle-with-a-real-world-coding-example-300x200.webp 300w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-liskov-substitution-principle-with-a-real-world-coding-example-1024x683.webp 1024w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-liskov-substitution-principle-with-a-real-world-coding-example-768x512.webp 768w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/explain-liskov-substitution-principle-with-a-real-world-coding-example-150x100.webp 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\"><\/p><h3>5. What are common violations of OOPS principles in production systems?<\/h3><p><strong>Common violations include:<\/strong><\/p><ul>\n<li>God classes handling multiple responsibilities.<\/li>\n<li>Excessive inheritance creating deep hierarchies.<\/li>\n<li>Hardcoded dependencies instead of interfaces.<\/li>\n<li>Ignoring encapsulation by exposing internal variables.<\/li>\n<li>Violating Open\/Closed Principle by modifying existing classes for new features.<\/li>\n<li>Tight coupling between modules.<\/li>\n<\/ul><p>These issues reduce maintainability and scalability.<\/p><h3>6. How does polymorphism improve extensibility in enterprise systems?<\/h3><p>Polymorphism allows new implementations without changing existing code.<\/p><p><strong>Benefits:<\/strong><\/p><ul>\n<li>Enables adding new subclasses without modifying parent logic.<\/li>\n<li>Supports Open\/Closed Principle.<\/li>\n<li>Allows interchangeable implementations through interfaces.<\/li>\n<li>Reduces conditional logic.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>Instead of:<br>\nif(type == &ldquo;CreditCard&rdquo;) {&hellip;}<br>\nelse if(type == &ldquo;UPI&rdquo;) {&hellip;}<\/p>\n<p>Use polymorphism:<br>\nPayment payment = new CreditCardPayment();<br>\npayment.pay();<\/p>\n<\/div><\/div><p>Adding new payment types requires only new classes.<\/p><h3>7. Compare Factory Pattern and Abstract Factory Pattern.<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Factory Pattern<\/b><\/td>\n<td><b>Abstract Factory Pattern<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Purpose<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Create single product<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Create families of related products<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Complexity<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Simpler<\/span><\/td>\n<td><span style=\"font-weight: 400;\">More complex<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Structure<\/span><\/td>\n<td><span style=\"font-weight: 400;\">One factory method<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Multiple related factory methods<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Use Case<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Creating one object type<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Creating multiple related objects<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Example<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Create different Payment objects<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Create UI components for different OS<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Factory creates individual objects. Abstract Factory creates groups of related objects without specifying concrete classes.<\/p><h3>8. Explain the Strategy Pattern and its practical use case.<\/h3><p>Strategy Pattern allows selecting an algorithm at runtime by encapsulating each algorithm inside separate classes.<\/p><p><strong>Structure:<\/strong><\/p><ul>\n<li>Strategy interface<\/li>\n<li>Concrete strategy implementations<\/li>\n<li>Context class using strategy<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example: Payment processing<\/strong><\/p>\n<p>interface PaymentStrategy {<br>\nvoid pay(int amount);<br>\n}<\/p>\n<p>class CreditCard implements PaymentStrategy {}<br>\nclass UPI implements PaymentStrategy {}<\/p>\n<\/div><\/div><p>This allows changing payment method dynamically without modifying core logic.<\/p><h3>9. How does the Observer pattern support event-driven design?<\/h3><p>Observer pattern defines a one-to-many dependency where changes in one object notify multiple observers automatically.<\/p><p><strong>Key components:<\/strong><\/p><ul>\n<li>Subject maintains observer list.<\/li>\n<li>Observers register with subject.<\/li>\n<li>Subject notifies observers on state change.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong> Stock price system notifying traders.<\/p>\n<\/div><\/div><p>This pattern supports event-driven systems by enabling asynchronous updates and loose coupling between publisher and subscribers.<\/p><h3>10. What is the difference between an interface-based design and an implementation-based design?<\/h3><table class=\"tablepress\">\n<thead><tr>\n<td><b>Feature<\/b><\/td>\n<td><b>Interface-Based Design<\/b><\/td>\n<td><b>Implementation-Based Design<\/b><\/td>\n<\/tr><\/thead><tbody class=\"row-striping row-hover\">\n\n<tr>\n<td><span style=\"font-weight: 400;\">Dependency<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Depends on abstraction<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Depends on concrete class<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Flexibility<\/span><\/td>\n<td><span style=\"font-weight: 400;\">High<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Low<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Testability<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Easy to mock<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Harder to test<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Extensibility<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Easy to extend<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Requires modification<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Coupling<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Loose<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Tight<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table><p>Interface-based design promotes loose coupling and scalability. Implementation-based design creates rigid systems that are harder to modify.<\/p><h3>11. How does garbage collection work in object-oriented languages?<\/h3><p>Garbage collection automatically reclaims memory occupied by objects that are no longer reachable in a program.<\/p><p><strong>In languages like Java:<\/strong><\/p><ul>\n<li>Objects are created in heap memory.<\/li>\n<li>The garbage collector identifies unreachable objects.<\/li>\n<li>Memory is reclaimed automatically.<\/li>\n<li>Developers do not manually free memory.<\/li>\n<\/ul><p><strong>Common GC concepts:<\/strong><\/p><ul>\n<li><strong>Mark and Sweep &ndash;<\/strong> Marks reachable objects and removes unmarked ones.<\/li>\n<li><strong>Generational GC &ndash;<\/strong> Divides heap into young and old generations for efficient cleanup.<\/li>\n<li><strong>Stop-the-world pauses &ndash;<\/strong> Short pauses during collection.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong> If an object reference becomes null and no other references point to it, it becomes eligible for garbage collection.<\/p>\n<\/div><\/div><h3>12. Explain object lifecycle in Java or C++.<\/h3><p><strong>In Java, the object lifecycle includes:<\/strong><\/p><ul>\n<li><strong>Loading &ndash;<\/strong> Class is loaded into memory.<\/li>\n<li><strong>Instantiation &ndash;<\/strong> Object created using new.<\/li>\n<li><strong>Initialization &ndash;<\/strong> Constructor initializes variables.<\/li>\n<li><strong>Usage &ndash;<\/strong> Methods are invoked during program execution.<\/li>\n<li><strong>Garbage Collection &ndash;<\/strong> Object becomes eligible for GC when no references exist.<\/li>\n<\/ul><p><strong>In C++, lifecycle differs:<\/strong><\/p><ul>\n<li>Objects may be created on stack or heap.<\/li>\n<li>Constructor initializes object.<\/li>\n<li>Destructor is called automatically when object goes out of scope or deleted.<\/li>\n<\/ul><p>Java relies on garbage collection, while C++ requires explicit memory management for heap objects.<\/p><h3>13. What are immutability and its benefits in concurrent systems?<\/h3><p>An immutable object cannot change its state after creation.<\/p><p>To create an immutable class:<\/p><ul>\n<li>Declare class as final.<\/li>\n<li>Make fields private and final.<\/li>\n<li>Provide no setters.<\/li>\n<li>Initialize fields via constructor.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>final class User {<br>\nprivate final String name;<\/p>\n<p>User(String name) {<br>\nthis.name = name;<br>\n}<\/p>\n<p>public String getName() {<br>\nreturn name;<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>Benefits in concurrent systems:<\/p><ul>\n<li>Thread-safe by default.<\/li>\n<li>No synchronization required.<\/li>\n<li>Prevents accidental state modification.<\/li>\n<li>Improves reliability in multi-threaded environments.<\/li>\n<\/ul><h3>14. How do you design thread-safe classes in OOPS?<\/h3><p>Thread safety ensures correct behavior when accessed by multiple threads.<\/p><p><strong>Strategies:<\/strong><\/p><ul>\n<li>Use synchronization (synchronized keyword).<\/li>\n<li>Use immutable objects.<\/li>\n<li>Use thread-safe collections.<\/li>\n<li>Apply locks (ReentrantLock).<\/li>\n<li>Minimize shared mutable state.<\/li>\n<li>Use atomic variables.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Counter {<br>\nprivate int count = 0;<\/p>\n<p>public synchronized void increment() {<br>\ncount++;<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>The synchronized method prevents race conditions.<\/p><h3>15. What are covariant return types?<\/h3><p>Covariant return types allow a subclass method to return a more specific type than the return type defined in the parent class.<\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Animal {<br>\nAnimal getInstance() {<br>\nreturn new Animal();<br>\n}<br>\n}<\/p>\n<p>class Dog extends Animal {<br>\nDog getInstance() {<br>\nreturn new Dog();<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>Here, the overridden method returns a subclass type (Dog), which is allowed in modern object-oriented languages.<\/p><h3>16. If a class hierarchy becomes too deep and complex, how would you redesign it?<\/h3><p>Deep hierarchies reduce maintainability and flexibility.<\/p><p><strong>Redesign strategies:<\/strong><\/p><ul>\n<li>Replace inheritance with composition.<\/li>\n<li>Extract interfaces for shared behavior.<\/li>\n<li>Flatten unnecessary levels.<\/li>\n<li>Apply SOLID principles.<\/li>\n<li>Use strategy pattern for dynamic behavior.<\/li>\n<\/ul><p><strong>Instead of:<\/strong><\/p><p>Class A &rarr; B &rarr; C &rarr; D &rarr; E<\/p><p><strong>Use:<\/strong><\/p><ul>\n<li>Base interface<\/li>\n<li>Independent components<\/li>\n<li>Composition-based relationships<\/li>\n<\/ul><p>This improves modularity and extensibility.<\/p><h3>17. How would you design a plugin-based system using OOPS?<\/h3><p>A plugin system allows dynamic extension without modifying core logic.<\/p><p><strong>Design approach:<\/strong><\/p><ul>\n<li>Define a common interface (e.g., Plugin).<\/li>\n<li>Implement concrete plugin classes.<\/li>\n<li>Use dependency injection or factory pattern.<\/li>\n<li>Load plugins dynamically at runtime.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example structure:<\/strong><\/p>\n<p>interface Plugin {<br>\nvoid execute();<br>\n}<\/p>\n<p>class PaymentPlugin implements Plugin {}<br>\nclass LoggingPlugin implements Plugin {}<\/p>\n<\/div><\/div><p>The main system interacts with plugins through the interface, enabling easy extension.<\/p><h3>18. How would you design a scalable notification system using OOPS principles?<\/h3><p><strong>Design considerations:<\/strong><\/p><ul>\n<li>Use interface-based design for notification channels.<\/li>\n<li>Implement strategy pattern for different channels (Email, SMS, Push).<\/li>\n<li>Use observer pattern for event triggering.<\/li>\n<li>Separate message formatting from delivery logic.<\/li>\n<li>Use dependency injection for flexibility.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example structure:<\/strong><\/p>\n<p>interface Notification {<br>\nvoid send(String message);<br>\n}<\/p>\n<p>class EmailNotification implements Notification {}<br>\nclass SMSNotification implements Notification {}<\/p>\n<\/div><\/div><p>This design allows adding new notification types without modifying existing code.<\/p><h3>19. How do you ensure backward compatibility when modifying base classes?<\/h3><p><strong>Best practices:<\/strong><\/p><ul>\n<li>Avoid changing public method signatures.<\/li>\n<li>Use method overloading instead of modification.<\/li>\n<li>Mark deprecated methods before removal.<\/li>\n<li>Follow Open\/Closed Principle.<\/li>\n<li>Maintain interface stability.<br>\nProvide default implementations when adding new methods.<\/li>\n<\/ul><p>This ensures existing subclasses continue functioning without breaking.<\/p><p><img decoding=\"async\" class=\"alignnone size-full wp-image-19493\" src=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/how-do-you-ensure-backward-compatibility-when-modifying-base-classes.webp\" alt=\"how do you ensure backward compatibility when modifying base classes\" width=\"1200\" height=\"800\" srcset=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/how-do-you-ensure-backward-compatibility-when-modifying-base-classes.webp 1200w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/how-do-you-ensure-backward-compatibility-when-modifying-base-classes-300x200.webp 300w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/how-do-you-ensure-backward-compatibility-when-modifying-base-classes-1024x683.webp 1024w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/how-do-you-ensure-backward-compatibility-when-modifying-base-classes-768x512.webp 768w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2026\/03\/how-do-you-ensure-backward-compatibility-when-modifying-base-classes-150x100.webp 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\"><\/p><h3>20. What trade-offs do you consider when designing reusable frameworks using OOPS?<\/h3><p><strong>Key trade-offs include:<\/strong><\/p><ul>\n<li><strong>Flexibility vs Complexity &ndash;<\/strong> More abstraction increases flexibility but adds complexity.<\/li>\n<li><strong>Performance vs Extensibility &ndash;<\/strong> Highly abstract designs may reduce performance.<\/li>\n<li><strong>Inheritance vs Composition &ndash;<\/strong> Inheritance simplifies reuse but may reduce flexibility.<\/li>\n<li><strong>Stability vs Innovation &ndash;<\/strong> Maintaining backward compatibility can limit rapid changes.<\/li>\n<\/ul><p>Designing reusable frameworks requires balancing extensibility, maintainability, and simplicity while avoiding over-engineering.<\/p><hr><h2>Scenario-Based Questions for OOPS Interviews<\/h2><hr><p><strong>1. You are designing a Student Management System. Each student has marks, and marks should not be modified directly from outside the class. How would you design this using OOPS principles?<\/strong><\/p><p>To solve this, encapsulation should be applied to protect internal data.<\/p><p><strong>Design approach:<\/strong><\/p><ul>\n<li>Make instance variables private.<\/li>\n<li>Provide public getter methods.<\/li>\n<li>Provide controlled setter methods with validation.<\/li>\n<li>Avoid exposing internal data structures directly.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>class Student {<br>\nprivate int marks;<\/p>\n<p>public int getMarks() {<br>\nreturn marks;<br>\n}<\/p>\n<p>public void setMarks(int marks) {<br>\nif (marks &gt;= 0 &amp;&amp; marks &lt;= 100) {<br>\nthis.marks = marks;<br>\n}<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>This ensures data validation and prevents unauthorized modifications, improving security and maintainability.<\/p><p><strong>2. You need to support multiple payment methods such as Credit Card and UPI in an application. How would you design it so new payment methods can be added later without modifying existing code?<\/strong><\/p><p>Polymorphism and interface-based design should be used.<\/p><p><strong>Design approach:<\/strong><\/p><ul>\n<li>Create a Payment interface.<\/li>\n<li>Implement separate classes for each payment method.<\/li>\n<li>Use interface reference in business logic.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example:<\/strong><\/p>\n<p>interface Payment {<br>\nvoid pay(double amount);<br>\n}<\/p>\n<p>class CreditCardPayment implements Payment {<br>\npublic void pay(double amount) {<br>\nSystem.out.println(&ldquo;Paid using Credit Card&rdquo;);<br>\n}<br>\n}<\/p>\n<p>class UPIPayment implements Payment {<br>\npublic void pay(double amount) {<br>\nSystem.out.println(&ldquo;Paid using UPI&rdquo;);<br>\n}<br>\n}<\/p>\n<\/div><\/div><p>This follows the Open\/Closed Principle because new payment types can be added without changing existing classes.<\/p><p><strong>3. A legacy system uses a deep inheritance hierarchy for different types of vehicles. Adding new vehicle types requires modifying multiple parent classes. How would you improve the design?<\/strong><\/p><p>Deep inheritance causes tight coupling and rigidity.<\/p><p><strong>Improvement strategy:<\/strong><\/p><ul>\n<li>Replace inheritance with composition.<\/li>\n<li>Extract common behaviors into interfaces.<\/li>\n<li>Use strategy pattern for dynamic behavior like fuel type or drive mechanism.<\/li>\n<li>Keep base classes minimal.<\/li>\n<\/ul><p><strong>Instead of:<\/strong><\/p><p>Vehicle &rarr; Car &rarr; ElectricCar &rarr; SmartElectricCar<\/p><p><strong>Redesign as:<\/strong><\/p><ul>\n<li>Vehicle interface<\/li>\n<li>Engine interface<\/li>\n<li>DriveStrategy interface<\/li>\n<\/ul><p>Composition improves flexibility and reduces dependency between classes.<\/p><p><strong>4. Your team reports that changes in one module frequently break another module due to direct object instantiation. How would you redesign this using OOPS principles?<\/strong><\/p><p>This indicates tight coupling.<\/p><p><strong>Solution approach:<\/strong><\/p><ul>\n<li>Introduce interfaces for dependencies.<\/li>\n<li>Use dependency injection instead of direct instantiation.<\/li>\n<li>Follow Dependency Inversion Principle.<\/li>\n<li>Reduce hardcoded object creation.<\/li>\n<\/ul><p><strong>Instead of:<\/strong><\/p><p>Report report = new PDFReport();<\/p><p><strong>Use:<\/strong><\/p><p>Report report = reportFactory.create();<br>\nOr inject dependency via constructor:<br>\nclass ReportService {<br>\nprivate Report report;<\/p><p>ReportService(Report report) {<br>\nthis.report = report;<br>\n}<br>\n}<\/p><p>This reduces dependency and improves testability.<\/p><p><strong>5. You are building a large-scale e-commerce platform where different discount strategies (seasonal, membership-based, coupon-based) need to be applied dynamically. How would you design this system using OOPS principles?<\/strong><\/p><p>The requirement suggests runtime flexibility and extensibility.<\/p><p><strong>Recommended design:<\/strong><\/p><ul>\n<li>Use Strategy Pattern.<\/li>\n<li>Define a DiscountStrategy interface.<\/li>\n<li>Implement different strategy classes.<\/li>\n<li>Inject strategy into Order or Checkout class.<\/li>\n<\/ul><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p><strong>Example structure:<\/strong><\/p>\n<p>interface DiscountStrategy {<br>\ndouble applyDiscount(double amount);<br>\n}<\/p>\n<p>class SeasonalDiscount implements DiscountStrategy {<br>\npublic double applyDiscount(double amount) {<br>\nreturn amount * 0.9;<br>\n}<br>\n}<\/p>\n<p>class MembershipDiscount implements DiscountStrategy {<br>\npublic double applyDiscount(double amount) {<br>\nreturn amount * 0.85;<br>\n}<br>\n}<\/p>\n<\/div><\/div><p><strong>The Checkout class uses the strategy:<\/strong><\/p><div class=\"su-note\" style=\"border-color:#dddfde;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#f7f9f8;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>class Checkout {<br>\nprivate DiscountStrategy strategy;<\/p>\n<p>Checkout(DiscountStrategy strategy) {<br>\nthis.strategy = strategy;<br>\n}<\/p>\n<p>double calculateTotal(double amount) {<br>\nreturn strategy.applyDiscount(amount);<br>\n}<br>\n}<\/p>\n<\/div><\/div><p><strong>Benefits:<\/strong><\/p><ul>\n<li>Follows Open\/Closed Principle.<\/li>\n<li>Easy to add new discount types.<\/li>\n<li>Avoids large conditional blocks.<\/li>\n<li>Supports runtime behavior changes.<\/li>\n<\/ul><hr><h2>OOPS MCQ Questions and Answers<\/h2><p>Preparing for objective-based rounds is just as important as understanding theoretical concepts in depth. <a href=\"https:\/\/www.placementpreparation.io\/mcq\/object-oriented-programming\/\">OOPS MCQs<\/a> help you quickly test your knowledge of core principles such as encapsulation, abstraction, inheritance, polymorphism, constructors, memory management, and design principles.<\/p><p><a href=\"https:\/\/www.placementpreparation.io\/mcq\/\">Practicing multiple-choice questions<\/a> improves speed, clarity, and accuracy before technical interviews and written tests. You can regularly practice structured OOPS MCQs on PlacementPreparation.io to strengthen your fundamentals and perform confidently in assessment rounds.<\/p><hr><h2>Final Words<\/h2><p>OOPS concepts form the foundation of modern software development and are frequently tested in technical interviews across languages like Java, C++, and Python. A strong understanding of core principles such as encapsulation, abstraction, inheritance, and polymorphism helps you write structured, maintainable, and scalable code.<\/p><p>Focus on understanding how these concepts are applied in real-world design rather than memorizing definitions. With consistent practice, coding implementation, and revision of interview-focused questions, you can confidently handle OOPS-related interview rounds at any level.<\/p><h2>Frequently Asked Questions<\/h2><h3>1. What are the most commonly asked OOPS interview questions?<\/h3><p>The most commonly asked OOPS interview questions focus on the four core principles, differences between abstraction and encapsulation, method overloading vs overriding, constructors, memory management, and SOLID principles.<\/p><h3>2. How should I prepare for OOPS interview questions as a fresher?<\/h3><p>Freshers should first understand core OOPS concepts clearly and practice writing simple class-based programs demonstrating inheritance, polymorphism, and encapsulation. Solving coding examples and reviewing output-based questions helps build confidence for technical interviews.<\/p><h3>3. What is the difference between OOPS theory questions and coding-based questions in interviews?<\/h3><p>Theory questions test conceptual clarity and understanding of principles, while coding-based questions evaluate practical implementation and problem-solving ability.<\/p><h3>4. Are SOLID principles important for OOPS interviews?<\/h3><p>Yes, SOLID principles are frequently asked in intermediate and experienced-level OOPS interviews because they reflect strong design knowledge. Understanding how these principles improve maintainability and scalability helps you answer architecture-level questions confidently.<\/p><h3>5. Why is OOPS important for software development and system design?<\/h3><p>OOPS promotes modular, reusable, and maintainable code by organizing programs around objects and responsibilities. It forms the foundation for scalable system design, clean architecture, and modern application development practices.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Preparing for a technical interview? OOPS is a core topic tested across languages like Java, C++, and Python.Interviewers assess your understanding of concepts such as encapsulation, abstraction, inheritance, and polymorphism, along with their practical implementation.This guide on OOPS interview questions and answers provides structured, interview-focused questions categorized by difficulty level to help you revise concepts [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":19136,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45],"tags":[],"class_list":["post-19114","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-interview-questions"],"_links":{"self":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts\/19114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/comments?post=19114"}],"version-history":[{"count":7,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts\/19114\/revisions"}],"predecessor-version":[{"id":19509,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts\/19114\/revisions\/19509"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/media\/19136"}],"wp:attachment":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/media?parent=19114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/categories?post=19114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/tags?post=19114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}