0% found this document useful (0 votes)
15 views

Abhi Java 1.2

The document describes a student experiment using abstract classes and subclasses in Java, where an abstract Book class is created with a title field and abstract setTitle method, and a MyBook subclass extends Book by implementing the setTitle method to set the title field. The student's program creates a MyBook object, sets its title through setTitle, and prints the title, demonstrating their understanding of abstract classes and subclasses. The student is evaluated on their experiment performance, viva voce, and submission of a work sheet recording the experiment.

Uploaded by

Abhinov Roy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Abhi Java 1.2

The document describes a student experiment using abstract classes and subclasses in Java, where an abstract Book class is created with a title field and abstract setTitle method, and a MyBook subclass extends Book by implementing the setTitle method to set the title field. The student's program creates a MyBook object, sets its title through setTitle, and prints the title, demonstrating their understanding of abstract classes and subclasses. The student is evaluated on their experiment performance, viva voce, and submission of a work sheet recording the experiment.

Uploaded by

Abhinov Roy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiment No. 1.

Student Name:Abhinov Kumar Roy UID: 21BCS9952


Branch: B.E(CSE) Section/Group: 802-B
Semester: 3rd Date of Performance:26-08-2022
Subject Name: OOPs using Java Subject Code: 21CSH-218

Aim of the practical: You have to create another class that extends the abstract class. Your task
is to write just the MyBook class.

Objective: In this challenge, we're going to use abstract class to create subclass of MyBook.

Program Code:

import java.util.*;
abstract class Book{
String title;
abstract void setTitle(String s);
String getTitle(){
return title;
}
}

class MyBook extends Book{


void setTitle(String s){
this.title = s;
}
}

public class Main{

public static void main(String []args){


Scanner sc=new Scanner(System.in);
String title=sc.nextLine();
MyBook new_novel=new MyBook();
new_novel.setTitle(title);
System.out.println("The title is: "+new_novel.getTitle());
sc.close();

}
}

Output:

Learning outcomes (What I have learnt):

1. I have learnt how to make abstract class in java.

2. I have learnt how to use this word in java.

3. I have learnt how to make subclass with the help of abstract class.
Evaluation Grid :

Sr. No. Parameters Marks Obtained Maximum Marks


1. Student Performance 12
(Conduct of experiment)
objectives/Outcomes.
2. Viva Voce 10
3. Submission of Work Sheet 8
(Record)
Total 30

You might also like