You are on page 1of 7

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment 1.2
Student Name: Rajendra Prasad Branch: BE-CSE
issar
UID: 21BCS9316 Section/Group: 703-A
Date of performance: 30-08-2022 Subject name: OOPs Using
Subject Code- 21CSH-218 JAVA

AIM: We have to create another class that extends the abstract class.
Then you can create an instance of the new class.

Notice that setTitle method is abstract too and has no body. That
means you must implement the body of that method in the child class.

OBJECTIVE:

To understand the concept of java abstract classes

Code-

import java.util.*; abstract


class Book
{

String title;
DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

abstract void setTitle(String s);


String getTitle()

{ return title;
}

class MyBook extends Book


{ void setTitle(String s){

title = s;
}}

public class A
{ 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());

}
DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING


}

Output –(Code)
DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING


DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING


Output –

Flowchart –
DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING


DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Learning Outcomes- 1. Learnt how to use Java


2. Learnt how to manipulate strings.
3. Learnt how to create abstract classes.

You might also like