0% found this document useful (0 votes)
3 views2 pages

Bindhu Inheritance Java

The document contains a Java program that defines a class hierarchy for managing student information, including their roll number and marks. It includes a 'Student' class, a 'test' class for handling marks, and a 'results' class that implements a 'sports' interface to calculate total marks. The main method creates an instance of the 'results' class and demonstrates the functionality by setting and displaying student details and marks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Bindhu Inheritance Java

The document contains a Java program that defines a class hierarchy for managing student information, including their roll number and marks. It includes a 'Student' class, a 'test' class for handling marks, and a 'results' class that implements a 'sports' interface to calculate total marks. The main method creates an instance of the 'results' class and demonstrates the functionality by setting and displaying student details and marks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.io.

*;
import java.lang.*;
class Student
{
int rollNumber;
void getNumber(int n)
{
rollNumber=n;
}
void printNumber()
{
System.out.println(“BINDHUJA B”)
System.out.println(“2322J1332”)
System.out.println("RollNo is"+rollNumber);
}
}
class test extends Student
{
float part1,part2;
void getMarks(float a, float b)
{
part1=a;
part2=b;
}
void putMarks()
{
System.out.println("Marks Part1 "+part1);
System.out.println("Marks Part2 "+part2);
}
}
interface sports
{
float sportwt=6.0F;
void putwt();
}
class results extends test implements sports
{
float total;
public void putwt()
{
System.out.println("Sports Marks "+ sportwt);
}
void display()
{
total=part1+part2+sportwt;
System.out.println("Total marks of " +rollNumber+" is "+total);
}
}
class Multiple
{
public static void main(String srgs[])
{
results a=new results();
a.getNumber(10);
a.printNumber();
a.getMarks(10.0F,25.5F);
a.putMarks();
a.putwt();
a.display();
}
}

You might also like