daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Mar 25th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2. class Person
  3. {
  4.   String name;
  5.   int age;
  6.   BufferedReader br;
  7.   void set() throws IOException
  8.   {
  9.     br = new BufferedReader(new InputStreamReader(System.in));
  10.     System.out.println("Enter name:");
  11.     name = br.readLine();
  12.     System.out.println("Enter age:");
  13.     age = Integer.parseInt(br.readLine());
  14.   }
  15.   void display()
  16.   {
  17.     System.out.println("Name: "+name);
  18.     System.out.println("Age: "+age);
  19.   }
  20. }
  21.  
  22. class Student extends Person
  23. {
  24.   String email,dept;
  25.   void set() throws IOException
  26.   {
  27.     super.set();
  28.     System.out.println("Enter Department:");
  29.     dept = br.readLine();
  30.     System.out.println("Enter email:");
  31.     email = br.readLine();
  32.   }
  33.  
  34.   void display()
  35.   {
  36.     super.display();
  37.     System.out.println("Department: "+dept);
  38.     System.out.println("Email: "+email);
  39.   }
  40. }
  41.  
  42. class Overriding
  43. {
  44.   public static void main(String args[]) throws IOException
  45.   {
  46.     Student s = new Student();
  47.     s.set();
  48.     s.display();
  49.   }
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top