Docsity

OOPS Interview Questions & Answers (Java) | Inheritance, Polymorphism + Output Questions, Summaries of Object Oriented Programming

Toggle sidebar
bg1
OOPS
INTERVIEW QUEStion & ANSwers
WHAT'S INSIDE
Important Interview Questions & Answers
Subtitle: For Placements & Technical Interviews
(B.Tech / MCA / CS / IT Students)
INDEX
What is OOPS?
Class & Object
Four Pillars of OOPS
Encapsulation
Abstraction
Inheritance
Polymorphism
Constructor & Destructor
Interface vs Abstract Class
OOPS Interview Tips
Getting Started
Q1. What is Object Oriented Programming?
Object Oriented Programming (OOPS) is a programming paradigm based on the concept of
objects, which contain data and methods.
Advantages:
Code reusability
Better security
Easy maintenance
pf3
pf4
pf5

Partial preview of the text

Download OOPS Interview Questions & Answers (Java) | Inheritance, Polymorphism + Output Questions and more Summaries Object Oriented Programming in PDF only on Docsity!

OOPS

INTERVIEW QUEStion & ANSwers

WHAT'S INSIDE

Important Interview Questions & Answers

Subtitle: For Placements & Technical Interviews (B.Tech / MCA / CS / IT Students)

INDEX

What is OOPS? Class & Object Four Pillars of OOPS Encapsulation Abstraction Inheritance Polymorphism Constructor & Destructor Interface vs Abstract Class OOPS Interview Tips

Getting Started

Q1. What is Object Oriented Programming?

Object Oriented Programming (OOPS) is a programming paradigm based on the concept of objects , which contain data and methods.

Advantages:

Code reusability Better security Easy maintenance

Real-world modeling

Q2. What are the main features of OOPS?

Encapsulation Abstraction Inheritance Polymorphism

Class And Object

Q3. What is a Class?

A class is a blueprint or template used to create objects.

Example: A class defines properties and behavior but does not occupy memory.

Q4. What is an Object?

An object is an instance of a class.

Key Points:

Objects represent real-world entities Memory is allocated only when an object is created

Q5. Difference between Class and Object.

Class Object

Blueprint Instance

No memory Memory allocated

Logical entity Physical entity

Encapsulation

INHERITANCE

Q10. What is Inheritance?

Inheritance allows a class to acquire properties and methods of another class.

Types of Inheritance:

Single Multilevel Hierarchical Multiple (via interfaces)

Q11. Advantages of Inheritance

Code reusability Reduced redundancy Easy maintenance

POLYMORPHISM

Q12. What is Polymorphism?

Polymorphism means many forms.

Types:

  1. Compile-time polymorphism (Method Overloading)
  2. Runtime polymorphism (Method Overriding)

Q13. Method Overloading vs Method Overriding.

Method overloading Method overriding

same method name same method signature

Different parameters same parameters

Compile time Runtime

Constructor & Destructor

Q14. What is a Constructor?

A constructor is a special method used to initialize objects.

Characteristics:

Same name as class No return type Automatically called

Q15. Types of Constructors

Default constructor Parameterized constructor

Q16. What is a Destructor?

A destructor is used to free memory when an object is destroyed. (Automatically handled in Java, manually in C++)

Interface VS Abstract class

Q17. Abstract Class

Can have abstract and non-abstract methods Supports constructors Supports access modifiers

Q18. Interface

Only abstract methods (Java < 8) No constructors Supports multiple inheritance