Object-Oriented Programming
1.Define OOPS?
Object-Oriented Programming is a programming methodology which offers a new model where data and processes are integrated. e.g: C++, C#, Java
2.What is Encapsulation ?
Short Answer: Binds code and data
Long Answer: Encapsulation is the mechanism that binds together the code and data it manipulates into a single unit and keeps them safe from external interference and misuse.
In C++ this is supported by a construct called class.
3.What is Data Abstraction ?
Short Answer: Hide background details
Long Answer: The technique of creating a new data type that are well suited to an application to be programmed is known as data abstraction.
e.g: Stack – We can use push & pop without bothering how the push and pop operations performed.
The class is a construct in C++ for creating user-defined data types called Abstract Data Types (ADT’s)
4.What is Polymorphism ?
Short Answer: Polymorphism means the ability to assume several forms.
Long Answer: Polymorphism refers to the ability of an entity to refer to objects of various classes at runtime.
5.What is Inheritance ?
Short Answer: Extension & reuse of existing code
Long Answer: Inheritance allows the extension & reuse of existing code (class) without having to rewrite the code from scratch. Inheritance involves the creation of a new class (derived class) from the existing ones (base classes)
The new derived class inherits the members of the base class and also adds its own.
e.g: Child inherits features from their parents refine some of them and add a few of their own.
6.What is Object-Based Language ?
Languages that do not support OOPS featurs like inheritance and polymorphism but only supports objects are called object-based language. e.g: Visual Basic
7.Why we use Interface ?
Interfaces provides the flexibility to change the Implemenatation with out breaking the existing clients. Interfaces are used in COM, EJB e.t.c