Professional Documents
Culture Documents
B
EXClass A
{
public void methodA()
{
System.out.println( Base Class Method);
}
}
{
public void methodB()
{
System.out.println(Child Class Method);
}
public static void main (String args [])
{
B obj= new B();
obj.method A();
obj.method B();
}
}
2. MULTIPLE INHERITANCE- It refers to the concept of one class extending
more than one base class or parent class. The problem with multiple
inheritance is that is derived class will have to manage the dependency on
two base classes
A
B
C
Note (1) - It is very rarely used in software projects. Using this inheritance often
leads to problems in the hierarchy. This results in unwanted complexity.
Note (2) - Most of new languages like small Talk, Java ,C++ do not support
Multiple Inheritance except C++
3. MULTILEVEL INHERITANCE- It refers to a mechanism in Object oriented
technology where one can inherit from a derived class . Thereby making this
derived class the base class for the new class.
A
B
EXAMPLEclass x
{
Public void methodY()
{
System.out.println(Class X method);
}
}
class Y extends X
{
public void methodY()
{
5. HYBRID INHERITANCE- In simple terms you can say that hybrid inheritance
is a combination of single & multiple inheritance. A hybrid inheritance can be
achieved in the java in a same way as a multiple inheritance can be. Using
interfaces. Yes it is right. By using interfaces you can have a multiple as well
as hybrid inheritance in Java.
A
USES
METHOD OVERRIDING
Final: - The final keyword in java is used to restrict the user from inheriting.
It can be used in many contexts. It can be used for a variable, method or class.
If you mark any variable as final, you cant change the value of that variable.
If you mark any method as final, you cannot override it.
If you make any class as final, you cannot extend it.
Advantages: The core advantages of exception handling is to maintain the normal flow of
the application. Exception normally disrupts the normal flow of the application.
That is why we use exception handling.
Keywords:
Try
Catch
Finally
Throw
Throws
Built in package
User defined package
Advantages: o
o
o