super() keyword important behavior
Java Programming Language Class, Object and Methods in java (Article) Class, Object and Methods in java (Program)
987Program:
class Student{ int id; String name; Student(int id,String name){ this.id=id; this.name=name; } } class Child extends Student{ int roll; Child(int id,String name,int roll){ super(id,name);//reusing parent constructor this.roll=roll; } void display(){ System.out.println(id+" "+name+" "+roll); } } class SuperKeyword { public static void main(String[] args){ Child e1=new Child(1,"Rahim",12); e1.display(); }}
Output:
1 Rahim 12 Press any key to continue . . .
This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.