0 ratings0% found this document useful (0 votes) 2 views2 pagesOops Interview Questions
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Basic
Theory Questions:
1. Encapsulation:
© What is encapsulation, and how does it help in data hiding?
© How do you implement encapsulation in Java?
2. Inheritance:
© What is inheritance, and how does it facilitate code reuse?
© Can a constructor be inherited in Java? Why or why not?
3. Polymorphism:
© What is polymorphism in OOP?
© Explain method overloading with an example.
4. Abstraction
© What is abstraction, and how does it differ from encapsulation?
© How do abstract classes and interfaces achieve abstraction in Java?
Coding Questions:
1. Encapsulation:
© Write a Java class that demonstrates encapsulation by using private fields and public getter/setter
methods,
2, Polymorphism:
© Implement method overloading for a simple calculator class that can add both integers and doubles
Intermediate B
Theory Questions:
1. Encapsulation:
© How does encapsulation improve modularity in software design?
© Can you explain the role of access modifiers in encapsulation?
2. Inheritance:
© Whats the difference between super and this keywords in Java?
© How does Java handle multiple inheritance, and why doesn't it support it directly?
3. Polymorphism:
© How does Java achieve runtime polymorphism?
© Can you explain the difference between method overriding and method hiding?
4, Abstraction
© How would you choose between an abstract class and an interface in Java?© What are the key differences between abstract classes and interfaces?
Coding Questions
1. Inheritance:
© Write a Java program that demonstrates multilevel inheritance and method overriding,
2. Polymorphism:
© Create a Java program that demonstrates runtime polymorphism by overriding methods in a
superclass and its subclass.
Advanced @
Theory Questions:
1. Encapsulation:
© How can encapsulation lead to increased complexity in large systems, and how can it be managed?
© Discuss how encapsulation is related to the concept of immutability in Java.
2. Inheritance:
© How would you prevent a class from being inherited in Java?
© Discuss the concept of covariant return types in Java and how they relate to inheritance,
3. Polymorphism:
© Explain the role of polymorphism in design patterns like the Strategy Pattern
© How does polymorphism affect performance in a large-scale application?
4 Abstraction
© How does abstraction influence the design of large-scale systems?
© Discuss the impact of abstraction on system performance and scalability
Coding Questions:
1. Encapsulation & Inheritance:
© Implement a class hierarchy for a banking system where Account is the superclass, and
SavingsAccount and CheckingAccount are subclasses, Demonstrate encapsulation by hiding the
account balance and inheritance by overriding methods,
2. Polymorphism:
© Design a program where different types of employees ( FullTimeEmployee, PartTimeEmployee ,
Contract Employee ) are represented using polymorphism. Each employee type should calculate
their salary differently, but all should implement a common interface.
3. Abstraction:
© Write an abstract class Shape with abstract methods area() and perimeter() . Implement
concrete classes like Circle, Rectangle, and Triangle that extend Shape and provide
implementations for the abstract methods.