由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - how to access the overrided fields of the parent?
相关主题
请教一个简单的问题问个基本问题
泛型问题问一个 java generic问题
1 quick interview questionoverride/overload/overwrite in Java
@Override annotation.Re: print problem, GUI guru please come in
为啥画不出来?extending generic class , but not mentioning its parameterized type?
这几个函数可以用Generic之类的东西合并么?Top Ten Errors Java Programmers Make(9)
Re: 如何在两个窗口之间通信?Core Java2 Notes (4)
who can help me with this dummy Question??answer Re: how HashMap/Hashtable compare key?
相关话题的讨论汇总
话题: overrided话题: fields话题: access话题: children话题: string
进入Java版参与讨论
1 (共1页)
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?

1 (共1页)
进入Java版参与讨论
相关主题
answer Re: how HashMap/Hashtable compare key?为啥画不出来?
how to copy an Object?这几个函数可以用Generic之类的东西合并么?
question about repaint, update and paintRe: 如何在两个窗口之间通信?
How to wrap line at specific position?who can help me with this dummy Question??
请教一个简单的问题问个基本问题
泛型问题问一个 java generic问题
1 quick interview questionoverride/overload/overwrite in Java
@Override annotation.Re: print problem, GUI guru please come in
相关话题的讨论汇总
话题: overrided话题: fields话题: access话题: children话题: string