0% found this document useful (0 votes)
7 views3 pages

Assignment 2

The document presents a Java program that demonstrates single inheritance by creating a subclass 'student' that extends a superclass 'teacher'. It includes methods for inputting and displaying data for both the teacher and the student. The program captures and displays information such as names, IDs, classroom numbers, and marks.

Uploaded by

mauli mane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Assignment 2

The document presents a Java program that demonstrates single inheritance by creating a subclass 'student' that extends a superclass 'teacher'. It includes methods for inputting and displaying data for both the teacher and the student. The program captures and displays information such as names, IDs, classroom numbers, and marks.

Uploaded by

mauli mane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

//Name: Mane Mauli Kundalik

//Class:SE DIV:3 Batch:B

//Roll no: 205C041

//Assignment no: 2

//Title:Create a java program demonstrating single inheritance where a


subclass extends a super class and calls its methods.

//PROGRAM:

package inheritence;

import [Link];

class teacher

private

Scanner input=new Scanner([Link]);

String name;

int cr_no;

int t_id;

void getdata()

[Link]("Enter name of Teacher: ");

name=[Link]();

[Link]("Enter Classroom no of Teacher: ");

cr_no=[Link]();

[Link]("Enter Teacher ID: ");

t_id=[Link]();

void display()

[Link]("Name of Teacher: "+name);

[Link]("ID of Teacher: "+t_ID);


[Link]("Classroom of Teacher: "+cr_no);

class student extends teacher

Scanner input =new Scanner([Link]);

String sname;

int ID;

double marks;

void get()

[Link]();

[Link]("Enter name of student: ");

sname=[Link]();

[Link]("Enter ID of student: ");

id=[Link]();

[Link]("Enter marks of student: ");

marks=[Link]();

void put()

[Link]();

[Link]("Name of student: "+sname);

[Link]("ID of student: "+ID);

[Link]("marks of student: "+marks);

public class single_inheritence {

public static void main(String[] args) {

student s1=new student();


[Link]();

[Link]();

//OUTPUT:

Enter name of Teacher:

VIRAT

Enter classroom no of Teacher:

32

Enter Teacher ID:

10112

Enter name of Student:

YASH

Enter ID of Student:

190210

Enter Marks of Student:

94.67

Name of Teacher: VIRAT

ID of Teacher: 10112

Classroom of Teacher: 29

Name of Student: YASH

Id of Student: 190210

Marks of Student: 94.67

You might also like