Inheritance

                                                            Inheritance


What is Inheritance ?
   The process of obtaining the data members and methods from one class to another
class is known as inheritance. It is one of the fundamental features of object-oriented
programming.

What are advantage of Inheritance ?
   If we develop any application using concept of Inheritance than that application have
following advantages,
· Application development time is less.
· Application take less memory.
· Application execution time is less.
· Application performance is enhance (improved).
· Redundancy (repetition) of the code is reduced or minimized so that we get
consistence results and less storage cost.

Why use Inheritance ?
· For Method Overriding (used for Runtime Polymorphism).
· It's main uses are to enable polymorphism and to be able to reuse code for different
classes by putting it in a common super class
· For code Re-usability

You can decrease scope of access modifier in inheritance ?
No, In Inheritance the scope of access modifier increasing is allow but decreasing is
not allow. Suppose in parent class method access modifier is default then it's present
in child class with default or public or protected access modifier but not private.

How many type of inheritance are allow in java ?
In Java following inheritance are allow;
· Single inheritance
· Multilevel inheritance
· Hierarchical inheritance
· Hybrid inheritance

Which inheritance is not supported by Java ?
Multiple Inheritance, are not supported by java.

Why multiple inheritance is not supported in java?
Due to ambiguity problem java does not support mutiple inheritance at class level.

How to achieve multiple inheritance in java ?
Java can not support multiple inheritance at class level but you can achieve multiple
inheritance in java by using Interface concept.

Difference between Inheritance and package ?
->  Package keyword is always used for creating the undefined package and placing
common classes and interfaces.
-> import is a keyword which is used for referring or using the classes and interfaces of a specific package.

 Give real life example of class and object?
In real world many examples of object and class like dog, cat, and cow are belong to
animal's class. Each object has state and behaviors.
  For example a dog has state:-color, name, height, age as well as behaviors:- barking, eating, and sleeping.