Monday, January 13, 2014

Java constructor Programming Example

//Note:  Analysis the programs errors,outputs and Understand the constructor concept in Java


//[1]

class A{
public int i;
A(){i=75;}
public void printi(){
System.out.println("superclass i="+i);
}
}
class B extends A{
public int j;
B(){
Super();
j=70;
}
}
public void printj(){
System.out.println("subclass j="+j);
}
}
class SupDemo57{
public static void main(String arg[]){
B obj=new B();
obj.printj();
obj.printi();
}
}








No comments: