SCJP模拟试题:SCJPMockExam(2)答案
来源:优易学  2009-11-28 16:26:14   【优易学:中国教育考试门户网】   资料下载   IT书店
文章页内部300*250广告位


Answer to Question 41)

Obje Question 41)

Objective 4.6)

4) Use the getText method of a Textfield and use the parseInt method of the Integer class

Here is an example of how you might do this

Integer.parseInt(txtInputValue.getText());

I'm not sure that a question on this actually will come up in the exam but it is a very useful thing to know in the real world.

--------------------------------------------------------------------------------

Answer to Question 42)

Objective 4.6)

4) none of the above

The wrapper classes are immutable. Once the value has been set it cannot be changed. A common use of the wrapper classes is to take advantage of their static methods such as Integer.parseInt(String s) that will returns an integer if the the value has been set it cannot be changed. A common use of the wrapper classes is to take advantage of their static methods such as Integer.parseInt(String s) that will returns an integer if the String contains one.

--------------------------------------------------------------------------------

Answer to Question 43)

Objective 6.2)

2) constructors cannot be overriden

Overloading constructors is a key technique to allow multiple ways of initialising classes. By definition constructors have noition constructors have no return values so option 3 makes no sense. Option 4 is the inverse of what happens as constructor code will execute starting from the oldest ancestor class downwards. You can test this by writing a class that inherits from a base class and getting the constructor to print out a message. When you create the child class you will see the order of constructor calling.

--------------------------------------------------------------------------------

Answer to Question 44)

Objective 7.1)

yield is a static method and causes whatever thread is currently executing to yield its cycles.

1) t.yield();
2) yield()

http://www.jchq.net/tutorial/07_01Tut.htm
JavaDoc for the Thread class
http://java.sun.com/products/jdk/1.2/docs/api/java/lang/Thread.html

--------------------------------------------------------------------------------

Answer to Question 45)

Objective 6.2)

4) Compilation and run with an output of 99

The fact that the variable court is declared as private does not stop the constructor from being able to initialise it.

--------------------------------------------------------------------------------

Ans to Question 46)">Answer to Question 46)

Objective 6.2)

3) To be overriden a method must have the same name, parameter and return types

Option 1 is a sneaky one in that it should read overriden not overloaded. An overriden method must also have the same return type. Parameter names are purely a programmer convenience and are not a factor in either overloading and overriding. Parameter order is a factor however.


Answer to Question 47)

Objective 6.2)

1) Compile time error

With the sun JDK it will produce the following error

"Only constructors can invoke constructors".

If you took out the call to super that causes this error the program would compile and at runtime it would output Base and then Checket as constructors are called from the oldest ancestor class downwards.

--------------------------------------------------------------------------------

Answer to Question 48)

Objective 1.2)

1) Static methods cannot be overriden to be non static

The JDK1.1 compiler will issue an error message "static methods cannot be overriden" if you atempt to do thiuot; if you atempt to do this. There is no logic or atempt to do this. There is no logic or reason why private methods should not be overloaded or that static methods should not be declared private. Option 4 is a jumbled up version of the limitations of exceptions for overriden methods

--------------------------------------------------------------------------------

Answer to Question 49)

Objective 3.1)

2) A program can suggest that garbage collection be performed but not force it
4) A reference becomes eligable for garbage collection when it is assigned to null

If a program keeps creating new references without any being discarded it may run out of memory. Unlike most aspects of Java garbage collection is platform dependent.

--------------------------------------------------------------------------------

Answer to Question 50)

Objective 1.2)

2) Compile time error

The main method is static and cannot access the non static variable x

--------------------------------------------------------------------------------

上一页  [1] [2] [3] [4] [5] [6] 下一页

责任编辑:小草

收藏此页】【 】【打印】【回到顶部
计算机文章页底部500*200广告
文章搜索:
 相关文章
计算机底部580*90广告
文章页右侧第一330*280广告
计算机文章页资讯推荐
热点资讯
文章页330尺寸谷歌广告位
热门课程培训