public class Person { private int age; private String name; public void setAge(int a) { age=a; } public void setName(String n) { name=n; } public int getAge() { return(age); } public String getName() { return(name); } } class Student extends person { private int rollno; public void setRollno(int r) { rollno=r; } public int getRollno() { return(rollno); } }public class Example { public static void main(String []args) { Student s1=new Student(); s1.getRollno(63); s1.setAge(18); s1.setName("smit"); System.out.println("roll no="+s1.getRollno()); System.out.println("name="+s1.getName()); System.out.println("age="+s1.getAge()); } }
person
Person
public class Person { ... } class Student extends person { ... }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)