Java Multiple Inheritance: Program Implementation

Write a program to implement the following Multiple Inheritance:
Class Student
Name, roll_no
Mark 1, Mark2

Interface: Exam
Percent_cal( )

Class: Result
Display( )

import java.lang.*;
import java.io.*;
interface Exam
{
	void percent_cal();
}
class Student
{
	String name;
	int roll_no,mark1,mark2;
	Student(String n, int r, int m1, int m2)
	{
		name=n;
		roll_no=r;
		mark1=m1;
		mark2=m2;
	}
	void display()
	{
		System.out.println ("Name of Student: "+name);
		System.out.println ("Roll No. of Student: "+roll_no);
		System.out.println ("Marks of Subject 1: "+mark1);
		System.out.println ("Marks of Subject 2: "+mark2);
	}
}
class Result extends Student implements Exam
{
	Result(String n, int r, int m1, int m2)
	{
		super(n,r,m1,m2);
	}
	public void percent_cal()
	{
		int total=(mark1+mark2);
		float percent=total*100/200;
		System.out.println ("Percentage: "+percent+"%");
	}
	void display()
	{
		super.display();
	}
}
class q10Multiple
{
	public static void main(String args[])
	{
		Result R = new Result("Ra.one",12,93,84);
		R.display();
		R.percent_cal();
	}
}

 

Rabins Sharma Lamichhane

Rabins Sharma Lamichhane is the owner of RabinsXP who is constantly working for increasing Internet of Things (IoT) in Nepal. He also builds android apps and crafts beautiful websites. He is also working with various social services. The main aim of Lamichhane is to digitally empower the citizens of Nepal and make the world spiritually sound better both in terms of technology and personal development.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *