Professional Documents
Culture Documents
:10
Aim: To Write Java Program on Abstract class and abstract methods.
Objectives:-Student/we will learn to use the abstract class and abstract methods in the java
program.
.
Theory:
A class which is declared as abstract is known as an abstract class. It can have abstract and non-
abstract methods. It needs to be extended and its method implemented. It cannot be instantiated.
A method which is declared as abstract and does not have implementation is known as an
abstract method.
Algorithm:
Step 1: Start
Step 7.Create a main method class twowheeler Create object of Bike class. Call run() and
Step 8: Stop.
Program(Code):
class twowheeler
{
public static void main(String args[])
{
Bike obj = new Honda();
obj.run();
obj.changeGear();
}
}
/*
Output:
D:\programs>javac twowheeler.java
D:\programs>java twowheeler
bike is created
running safely..
gear changed
D:\programs>
*/
Outcome: with this we/student will able to create user defined package and import it in the java
program.