SCJP问题:大家帮忙看看
awers 2004-11-01 12:21:46 Q1:Collection 里的哪些类是FINAL的?例如java.util.Vector,我在JDK文档里没查到
Q2:The default constructor has the same access as its class.(true?false?)
-------------------------------------------------------
Q3:
ClassOne.java:
1.package com.abe.pkg1;
2.public class ClassOne{
3.private char var='a';
4.char getVar(){return var;}
5.}
ClassTest.java
1.package com.abe.pkg2;
2.import com.abc.pkg1.ClassOne;
3.public class ClassTest extends ClassOne{
4.public static void main(String []args){
5.char a = new ClassOne().getVar();
6.char b = new ClassTest().getVar();
7.}
8.}
A.Compilation fails.
B.Compilation succeeds and no exceptions are thrown.
C.An exception is thrown at line5 in ClassTest.java.
D.An exception is thrown at line6 in ClassTest.java.
---------------------------------------------------------
Q4.When is the Demo object,created on line 3,eligible for garbage collection?
1.class Test{
2.private Demo d;
3.void start(){
4.d = new Demo();
5.this.takeDemo(d);
6.}
7.
8.void takeDemo(Demo demo){
9.demo = null;
10.demo = new Demo();
11.}
12.}
A.After line 5.
B.After line 9.
C.After the start() method completes.
D.When the takeDemo() method completes
E.When the instance running this code is made eligible for garbage for garbage collection.
---------------------------------------------------
除了Q1和Q2
请大家说明答案和原因,谢谢了先~~~~