oops basic questions Part-2

What is polymorphism?
It is the ability of an object to behave differently on different situations for the same message.
What is inheritance?
Inheritance is process of create new classes from existing classes.New classes inherits the properties of existing class the inherited class is called super class and the inherited class is called sub class.
It is useful to reuse existing code.
What are the drawbacks of inheritance?
Since inheritance inherits everything from the super class and interface, it may make the subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading in some situation. In addition, the inheritance may make peers hardly understand your code if they don't know how your super-class acts.
Types of inheritances
Single Inheritance
Multiple Inheritances
Hierarchical Inheritance
Multilevel Inheritance
Hybrid Inheritance
Multipath Inheritance
Why java does not support multiple inheritances?
Because Multiple-Inheritance causes for redundancy.
What is diamond problem?
The diamond problem is an ambiguity that can occur when a class multiply inherits from two classes that both descend from a common super class.
What is a variable?
A variable is named memory location which can hold a value and that value can be modified further.
A variable always represents one data type.
Types of variables
Local variables
Instance variables
Static variables
Final variables
Transient variables
Volatile variable
What is static?
static means one per class. static variables are created when the class loads. They are associated with the class. In order to access a static we don't need objects. We can directly access static methods and variable by calling classname.variablename.
What are a class, member and local variable?
Variables declared within a method are local variables. Variables declared within the class are member variables. Variables declared within the class with static modifier are class variables
What is the difference between static and nonstatic variables?
A static variable is associated with the class as a whole rather than with specific instances of a class. There will be only one value for static variable for all instances of that class. Non-static variables take on unique values with each object instance.
oops basic questions Part-1