f****y 发帖数: 70 | 1 142. Which two statements are true? (Choose Two)
A.An anonymous inner class can be declared inside of a method.
B.An anonymous inner class constructor can take arguments in some situation.
C.An anonymous inner class that is a direct subclass that is a direct subcla
ss of Object can implement multiple interfaces .
D.Even if a class Super does not implement any interfaces, it is still possi
ble to define an anonymous inner class that is an
immediate subclass of Super that implements a single inter | F****n 发帖数: 3271 | 2 AB
【在 f****y 的大作中提到】 : 142. Which two statements are true? (Choose Two) : A.An anonymous inner class can be declared inside of a method. : B.An anonymous inner class constructor can take arguments in some situation. : C.An anonymous inner class that is a direct subclass that is a direct subcla : ss of Object can implement multiple interfaces . : D.Even if a class Super does not implement any interfaces, it is still possi : ble to define an anonymous inner class that is an : immediate subclass of Super that implements a single inter
| f****y 发帖数: 70 | 3 答案看上去是对的,
多谢分析一下。
【在 F****n 的大作中提到】 : AB
| n*****k 发帖数: 123 | 4
Should be AC, B is apparent wrong, how can an anonymous class has a
constructor, it simply can not have any constructors cause any constructor
definition need a name. So an anonymous inner class simply uses the
constructors of it's superclass. All the auguments passed in is going to
superclass. So if inner class implements an interface, it can not take any
arguments.
A. is the main reason why you may think use the inner class, lazy!!! hehe.
C. Is right, bacause any inner class is an instant ext
【在 f****y 的大作中提到】 : 答案看上去是对的, : 多谢分析一下。
| F****n 发帖数: 3271 | 5 anonymous class's constructor is implicit declared from the class it extends,
and has
the exact signature of its super class. For example, if we have a class ClassA
with a constructor ClassA(x,y), we can have anonymous class like
ClassA classA = new ClassA(x,y) {
...method overriden...
};
As to C, how can an anonymous class that is a DIRECT subclass of Object
implements anything?
still
【在 n*****k 的大作中提到】 : : Should be AC, B is apparent wrong, how can an anonymous class has a : constructor, it simply can not have any constructors cause any constructor : definition need a name. So an anonymous inner class simply uses the : constructors of it's superclass. All the auguments passed in is going to : superclass. So if inner class implements an interface, it can not take any : arguments. : A. is the main reason why you may think use the inner class, lazy!!! hehe. : C. Is right, bacause any inner class is an instant ext
| F****n 发帖数: 3271 | 6 Sorry, C is right if we have an interface extends multiple interfaces.
extends,
ClassA
direct
still
【在 F****n 的大作中提到】 : anonymous class's constructor is implicit declared from the class it extends, : and has : the exact signature of its super class. For example, if we have a class ClassA : with a constructor ClassA(x,y), we can have anonymous class like : ClassA classA = new ClassA(x,y) { : ...method overriden... : }; : As to C, how can an anonymous class that is a DIRECT subclass of Object : implements anything? :
| f****y 发帖数: 70 | 7 Thanks for discussion.
So can I make the conclusion?
The answer is AC.
A. obviously
B. the description is not suitable, because inner class has no constructor a
lthough can use the constructor of super, even with parameters.
C. can implements from one interface which extends multi interfaces.
D. E If the inner class extends one class which don't implements any interfa
ce, it has no way to implements any interface.
【在 F****n 的大作中提到】 : Sorry, C is right if we have an interface extends multiple interfaces. : : extends, : ClassA : direct : still
|
|