Advertisement
d1i2p3a4k5

18.java18

Oct 19th, 2014
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.*;
  2. class student
  3. {
  4.     int roll;
  5.     void accept()
  6.     {
  7.         Scanner t = new Scanner (System.in);
  8.         System.out.println("enter roll no.");
  9.         roll = t.nextInt();
  10.     }
  11.     void display()
  12.     {
  13.         System.out.println("Roll no "+roll);
  14.     }
  15. }
  16. class test extends student
  17. {
  18.     int m1,m2;
  19.     void accept()
  20.     {
  21.         super.accept();
  22.         Scanner t = new Scanner(System.in);
  23.         System.out.println("enter m1 and m2");
  24.         m1 = t.nextInt();
  25.         m2 = t.nextInt();
  26.     }
  27.     void display()
  28.     {  
  29.         super.display();
  30.         System.out.println("m1 = "+m1+"m2 = "+m2);
  31.     }
  32. }
  33. interface sport
  34. {
  35.     final static int score = 99;
  36.    
  37. }
  38. class result extends test implements sport
  39. {
  40.     int total=0;
  41.     void accept()
  42.     {  
  43.         super.accept();
  44.         total = m1+m2+score;
  45.     }
  46.     void display()
  47.     {
  48.         super.display();
  49.         System.out.println("Score = "+score);
  50.         System.out.println("Total = "+total);
  51.     }
  52. }
  53. class java18
  54. {
  55.     public static void main(String args[])
  56.     {  
  57.         result r = new result();
  58.         r.accept();
  59.         r.display();
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement