+ 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"); } }
2 ответов
0
Base b=new Derived();
b.base();
((Derived)b).derived(); //cast it to type Derived
+ 1
thanks naomi, i will try this