Professional Documents
Culture Documents
abstract
return-type
methodName(ParameterListrf)
ABSTRACT EXAMPLE
abstract class AbstractMethods{ public void test ();// Compile error need to use abstract keyword
abstract int test (int a); abstract boolean test ();// can be overloaded abstract Object display(); }
1.abstract methods need to use abstract keyword 2.abstract methods can not have a method body 3.abstract methods should end with a semi colon ;
ABSTRACT CLASS
When a class is having at least one abstract method the class itself must be abstract. But if a class is abstract it does not require to have abstrac methods. Source Code
abstract class AbstractMethods{ abstract int test (int a); public Object display(){} }
ABSTRACT CLASS
Abstract classes cant make objects.
abstract class AbstractMethods{//Compile error public static void main(String args[]){ AbstractMethods a=new AbstractMethods();//Compile error } }
abstract class Animal{ public void eat(); public void walk();//Must Implement } class Cat extends Animal{ public void eat(){ System.out.print(Eating fish and rice) } }
END