Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class Person
- {
- String name;
- int age;
- BufferedReader br;
- void set() throws IOException
- {
- br = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Enter name:");
- name = br.readLine();
- System.out.println("Enter age:");
- age = Integer.parseInt(br.readLine());
- }
- void display()
- {
- System.out.println("Name: "+name);
- System.out.println("Age: "+age);
- }
- }
- class Student extends Person
- {
- String email,dept;
- void set() throws IOException
- {
- super.set();
- System.out.println("Enter Department:");
- dept = br.readLine();
- System.out.println("Enter email:");
- email = br.readLine();
- }
- void display()
- {
- super.display();
- System.out.println("Department: "+dept);
- System.out.println("Email: "+email);
- }
- }
- class Overriding
- {
- public static void main(String args[]) throws IOException
- {
- Student s = new Student();
- s.set();
- s.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement