Thursday, February 25, 2016

Java Programme (java inheritance example)

Java Programme
* java inheritance example

A class that is derived from another class is called subclass and inheritsall fields and methods of its superclass. In Java, only single inheritance is allowed and thus, every class can have at most one direct superclass

class A
{
public void print()
{
System.out.println("There are some problem creating in your System!!! Please scan your System either if you not clean your System it will be distroyed!!!");
}
}
class B extends A
{
public static void main(String args[])
{
B b1=new B();
b1.print();
}
}

Answer is :-  "There are some problem creating in your System!!! Please scan your System either if you not clean your System it will be distroyed!!!"

No comments:

Post a Comment