0

Why we create abstract method insted of normal method? At the first place

abstract class A { abstract void display (); } class B extends A { void display(){ System.out.println(" Why i am not created on the first place? "); } } class Main{ public static void main (String[]ar){ A obj = new A(); obj.display(); } }

18th Jul 2017, 2:55 AM
lzy gyz
lzy gyz - avatar
1 ответ
+ 5
In some cases, there's no common behavior for a method in the super class and you want each sub class to have its own implementation of that method, you'd make that method in super class abstract.
18th Jul 2017, 3:23 AM
Bàng Tứ Cường
Bàng Tứ Cường - avatar