/*To display student record’s thrg inheri*/
/*Save as: inherited*/
import java.lang.*; class Student_information { int id; String name,addr; Student_information(int id,String name,String addr) { this.id=id; this.name=name; this.addr=addr; } void display() { System.out.println("information of student"); System.out.println("id"+id); System.out.println("name"+name); System.out.println("address"+addr); } } class Student_record extends Student_information { String branch,sem; Student_record(int id,String name,String addr,String branch,String sem) Super(id,name,addr); { this.branch=branch; this.sem=sem; } void display() { display(); System.out.println("student record"); System.out.println("branch"+branch); System.out.println("sem"+sem); } } class inherited { public static void main(String args[]) { Student_record s1=new Student_record(47,"student A","har","bca","second"); Student_record s2=new Student_record(49,"student B","mah","bca","second"); Student_record s3=new Student_record(11,"student C","delhi","cs","third"); s1.display(); s2.display(); s3.display(); } }
No comments:
Post a Comment