Thursday, 8 October 2015

Java Inheritance example Program


public class Demo {

public static void main(String[] args) {
// TODO Auto-generated method stub

SubClass obj = new SubClass();

obj.display();

}

}




public class First {
protected String str;
First() {
str = "Java ";
}
}
 
class SubClass extends First {
SubClass() {
str = str.concat("Is My World ...!!!");
}
void display()
{
System.out.println(str);
}
}

output:-
Java Is My World ...!!!

No comments:

Post a Comment