Monday, 12 October 2015

Abstract class example in java


public class First {

public static void main(String[] args) {
// TODO Auto-generated method stub
Second reff = new four();
reff.display();
reff.first();
}

}


public abstract class Second {
abstract void display();
abstract void first();
}

abstract class Third extends Second{
//abstract void first();
void display(){
System.out.println("Third method");
}
}
class four extends Third{
void first(){
System.out.println("four method");
}
}

output:-
Third method
four method


No comments:

Post a Comment