DEPARTMENT OF
COMPUTER SCIENCE &
Experiment No. 1.2
Student Name: Aman kumar bhati UID: 21BCS2982
Branch: CSE Section/Group: 609 A
Semester: 3rd Date of Performance: 30/08/2022
Subject Name: Object Oriented Programming Subject Code: 21CSH-218
Using Java
Aim of the practical: Create an abstract class Book and then a child class
MyBook that extends the abstract class. In the Main class, we created an instance
of the child class MyBook. The setTitle() method is abstract too and has no
[Link] means it must be implemented in the child class MyBook.
Objective: To learn the concepts of abstract class in java.
Program Code:
import [Link].*;
abstract class Book
{
String title;
abstract void setTitle (String s);
String getTitle ()
{
return title;
}
DEPARTMENT OF
COMPUTER SCIENCE &
}
abstract class Bank
{
abstract void getBalance ();
}
class BankA extends Bank
{
void getBalance ()
{
int a = 1000;
}
}
class MyBook extends Book
{
void setTitle (String s)
{
title = s;
}
}
public class Main
{
public static void main (String[]args)
{
Scanner sc = new Scanner ([Link]);
DEPARTMENT OF
COMPUTER SCIENCE &
String title = [Link] ();
MyBook new_novel = new MyBook ();
new_novel.setTitle (title);
[Link] ("The title is: " + new_novel.getTitle ());
[Link] ();
}
}
Output:
Learning outcomes (What I have learnt):
1. Understand the basic concepts of Java.
2. How to take user inputs in java using Scanner.
DEPARTMENT OF
COMPUTER SCIENCE &
Evaluation Grid:
Sr. No. Parameters Marks Obtained Maximum Marks
1. Student 12
Performance
(Conduct of
experiment)
objectives/Outcomes.
2. Viva Voce 10
3. Submission of Work 8
Sheet (Record)
Total 30