Basic oops Concepts for Interview
OOPS, which is nothing but set of rule and regulation or formula or syntax. When we use it our program will optimize or perfect.
- Class & Object
- Data Abstraction
Class & Object
- class is defined as a collection of object or blueprint
- Object is an entity that has state and behavior
- with the object of child class, you can access the parent variable and function
- Single inheritance
- Multilevel inheritance
- Hierarchical inheritance
- Hybrid inheritance
- Reusing code
- Memory management
- Multiple Inheritance does not support in java
It is ability of data to be processed in more than one form
- Method overloading – ( Compile time polymorphism)——>function have same name but different argument
- Method overriding – ( Runtime polymorphism)——>return type, no. of argument in both parent and child classes , while exacting only child class function will run
It will show only essential information and hide “unnecessary” information
for example: ATM machine, it will show only essential data and unessential data
- It is restricted, class that cannot be used to create object
- It contain abstract method, which contains only declaration, implementation, is done in child class
- It can also have regular method.
- It can Inherited using extends keyword.
- It provide data hiding and security
- For design purpose, a class can be point to objects of its sub-classes, thereby achieving run time
It is a process of wrapping code and data together into a single unit.
- Interface methods do not have a body that body is provided by the implements class on implementation of an interface, you must override all of its Method.
- Interface methods are by default abstract and public
- Interface attributes are by default public, Static and final
- An interface cannot contain a constructor as it Cannot be used to create object
- It is used in case of multiple inheritance as Java doesn’t support it
- An interface reference can point to objects of its implementing classes.
- Constructor is a special type of function inside a class which is used to initialize to object variable
- Constructor is a special type of subroutine called to create an object
This: is a keyword always point to object
Super: is a keyword, it will point to the immediate