Advertisement
Swampert420

Untitled

Aug 5th, 2022
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. package Interface;
  2.  
  3. class Student {
  4.     int id;
  5.     public Student(int id) {
  6.         this.id = id;
  7.         System.out.println("ID of the student is: "+this.id);
  8.     }
  9. }
  10.  
  11. class Marks extends Student {
  12.     int marks;
  13.     public Marks(int marks){
  14.         super(2);
  15.         this.marks = marks;
  16.         System.out.println("Marks of the student are: "+this.marks);
  17.     }
  18. }
  19.  
  20. class Subject extends Marks {
  21.     String subject;
  22.     public Subject(String subject){
  23.         super(89);
  24.         this.subject = subject;
  25.         System.out.println("Subject of the student is: "+this.subject);
  26.     }
  27. }
  28.  
  29. public class PrintDetails {
  30.  
  31.     public static void main(String[] args) {
  32.         Subject sj = new Subject("English");
  33.     }
  34.    
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement