Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Student {
- String name;
- int id;
- void getDetails(String n, int i) {
- name = n;
- id = i;
- }
- void showDetails() {
- System.out.println("Name: " + name);
- System.out.println("ID: " + id);
- }
- }
- class Exam extends Student {
- int marks1;
- int marks2;
- void getMarks(int marks1, int marks2) {
- this.marks1 = marks1;
- this.marks2 = marks2;
- }
- void putMarks() {
- System.out.println("Marks 1: " + marks1);
- System.out.println("Marks 2: " + marks2);
- }
- }
- interface Sports {
- int sportwt = 7;
- void putWt();
- }
- class Result extends Exam implements Sports {
- public void putWt() {
- System.out.println("Sport Weight: " + sportwt);
- }
- int total;
- void totalMarks() {
- total = marks1 + marks2 + sportwt;
- }
- void display() {
- showDetails();
- putMarks();
- putWt();
- System.out.println("Total Marks: " + total);
- }
- }
- class DemoMain {
- public static void main(String[] args) {
- Result result = new Result();
- result.getDetails("Arijit", 29);
- result.getMarks(80, 85);
- result.totalMarks();
- result.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement