+ 5

Please help me with this program.

public class Test{ public static void main(String[] args){ Base b=new Derived(); b.derived(); } } class Base { public void base(){ System.out.println("base"); } } class Derived extends Base{ public void derived(){ System.out.println("derived"); } }

11th Jul 2018, 5:22 PM
Tarika
Tarika - avatar
2 odpowiedzi
0
Base b=new Derived(); b.base(); ((Derived)b).derived(); //cast it to type Derived
11th Jul 2018, 6:26 PM
naomi
naomi - avatar
+ 1
thanks naomi, i will try this
11th Jul 2018, 6:29 PM
Tarika
Tarika - avatar