两个看来相似的问题# Programming - 葵花宝典
G*A
1 楼
问题1:
assume that WhiteOnBlackLabel inherits a paint method from JLabel and also
implements its own version of paint.
JLabel label = new WhiteOnBlackLabel("A label");
label.paint(g); //for some Graphics object g
Which of those two implementations of paint will be executed in
label.paint(g); of this example?
paint() defined in label or paint() defined in WhiteOnBlacklabel?
问题2:
All of our Fruits inherit an equals method from class Object. Suppose that
Fruit declares its own equals method:
Object>
assume that WhiteOnBlackLabel inherits a paint method from JLabel and also
implements its own version of paint.
JLabel label = new WhiteOnBlackLabel("A label");
label.paint(g); //for some Graphics object g
Which of those two implementations of paint will be executed in
label.paint(g); of this example?
paint() defined in label or paint() defined in WhiteOnBlacklabel?
问题2:
All of our Fruits inherit an equals method from class Object. Suppose that
Fruit declares its own equals method:
Object>