mane use of abstract keyword is achieve abstract class.for classes abstract keyword is non access modifier in java, method but not variable . abstract is a one of the pillar of object oriented program(OOP).
important rule in abstract class:
any class that having one or more then one abstract method it is also declare abstract method.
the following are various illegal combination of other modifier for methods with respect to abstract modifier.
- final
- abstract native
- abstract synchronize
- abstract static
- abstract private
- abstract strictfp
abstract class Vehicle
{
abstract void bike();
}
class Honda extends Vehicle
{
void bike() {
System.out.println("Bike is running");
}
}
public class abex {
Honda obj=new Honda();
obj.bike();
}
}
Output :-
0 Comments