class ClassA { public int numberOfInstances; protected ClassA(int numberOfInstances) { this.numberOfInstances = numberOfInstances; } } class ExtendedA extends ClassA { private ExtendedA(int numberOfInstances) { super(numberOfInstances); } public static void main(String[] args) { ExtendedA ext = new ExtendedA(420); System.out.print(ext.numberOfInstances); } }
What is the result?
A. 420 is the output
B. An exception is thrown at runtime.
C. All constructors must be declared public.
D. Constructors CANNOT use the private modifier.
E. Constructors CANNOT use the protected modifier.
答案:A
解析:
這題挺仁慈的
没任何陷阱
好好導出結果來就是了
0 意見:
張貼留言