Yahoo interview question
What are Abstraction, Encapsulation, Polymorphism, and Inheritance?
Interview Answers
Abstraction
- Providing essential general features without providing implementation details using an abstract class or an interface.
Encapsulation
- Key advantage of using an object oriented programming language like java is that it provides your code security, flexibility and easy maintainability through encapsulation.
- helps in binding data and member functions of a class
- useful in hiding data of a class from an illegal direct access
Polymorphism
- having multiple forms. taking place when an object is accessed in multiple ways.
- when an object is accessed using reference variable of it's own class
- object is accessed by using reference variable of it's super class.
- there are 2 types of polymorphism
Inheritance
The two types of polymorphisms are : Compile time and runtime polymorphisms
Compile time polymorphism is observed at the time of overloading
Runtime / dynamic polymorphism is observed at the time of overriding
Inheritance is the process of creating a new class using another existing class. The class wanting to use the feature of another class is called the subclass wheares the class who features are to be used is referred to as super class.