Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pkgday3;
- class Person
- {
- public void Name(String Name)
- {
- System.out.println("name of a person:" +Name);
- }
- public void Year(int Year)
- {
- System.out.println("year of birth of a person:" +Year);
- }
- }
- class Student extends Person
- {
- public void Major(String major)
- {
- System.out.println("major of a person:" +major);
- }
- }
- class Instructor extends Person
- {
- public void salary(double Salary)
- {
- System.out.println("salary of a person:" +Salary);
- }
- }
- public class Q2
- {
- public static void main(String[] args)
- {
- Person p=new Person();
- p.Name("xyz");
- p.Year(1996);
- Student s1= new Student();
- s1.Major("Maths");
- Instructor i1= new Instructor();
- i1.salary(5000.0);
- }
- }
Add Comment
Please, Sign In to add comment