n*****r 发帖数: 9 | 1 In Java, fields and methods can be overrided, but they can
be accessed in Children's method body via super.
But can they be accessed outside Children's method body?
e.g
public class A{
public String t;}
class B extends A{
public int t;}
B b=new B();
now how to access b's overrided String t?
Thanks! | m******t 发帖数: 2416 | 2
If this is an interview question, it's a bad interview question.
If this is an actual design, it's a bad design.
【在 n*****r 的大作中提到】 : In Java, fields and methods can be overrided, but they can : be accessed in Children's method body via super. : But can they be accessed outside Children's method body? : e.g : public class A{ : public String t;} : class B extends A{ : public int t;} : B b=new B(); : now how to access b's overrided String t?
|
|