SCJP试题-SCJPMockExam3

来源:java认证发布时间:2012-11-12 12:48:16java认证视频


Answer 15)
Objective 8.2)
1) ipadx2) fill3) insets
--------------------------------------------------------------------------------

Answer 16)
Objective 8.2)
2) The buttons will run from left to right along the top of the
frameThe call to the setLayout(new FlowLayout()) resets the Layout
manager for the entire frame and so the buttons end up at the top rather than
the bottom.
--------------------------------------------------------------------------------

Answer 17)
Objective 8.2)
2) It is a field of the GridBagConstraints class for controlling component
placement3) A valid settting for the anchor field is
GridBagconstraints.NORTH
--------------------------------------------------------------------------------

Answer 18)
Objective 7.1)
4) Clean compile but no output at runtime
This is a bit of a sneaky one as I have swapped around the names of the
methods you need to define and call when running a thread. If the for loop were
defined in a method calledpublic void run()
and the call in the main method had been to b.start()
The list of values from 0 to 9 would have been
output.
--------------------------------------------------------------------------------

Answer 19)
Objective 8.2)
2) falseYou can re-use the same instance of the GridBagConstraints
when added successive components.
--------------------------------------------------------------------------------

Answer 20)
Objective 10.1)
4) An interface that ensures that implementing classes cannot contain
duplicates
--------------------------------------------------------------------------------

Answer 21)
Objective 10.1)
2) The add method returns false if you attempt to add an element with
a duplicate value
I find it a surprise that you do not get an
exception.
--------------------------------------------------------------------------------

Answer 22)
Objective 7.1)
1) The program exits via a call to exit(0);2) The priority of another
thread is increased3) A call to the stop method of the Thread class
Java threads are somewhat platform dependent and you should be carefull
when making assumptions about Thread priorities. On some platforms you may find
that a Thread with higher priorities gets to "hog" the processor. You can read
up on this in more detail at http://java.sun.com/docs/books/tutorial/essential/threads/priority.html
--------------------------------------------------------------------------------

Answer 23)
Objective 4.1)
4) The class can only access final variables
--------------------------------------------------------------------------------

Answer 24)
Objective 7.1)
1) To call from the currently running thread to allow another thread of
the same or higher priority to run
Option 3 looks plausible but there is no guarantee
that the thread that grabs the cpu time will be of a higher priority. It will
depend on the threading algorithm of the Java Virtual Machine and the underlying
operating system
--------------------------------------------------------------------------------

Answer 25)
Objective 6.2)
4) Compilation and running with output 0 to 9
--------------------------------------------------------------------------------

Answer 26)
Objective 2.1)
1) None of these optionsBecause of the
lack of a break statement after the break 10; statement the actual output will
be "ten" followed by "twenty"
--------------------------------------------------------------------------------

Answer 27)
Objective 3.1)
4) System.gc();
--------------------------------------------------------------------------------

Answer 28)
Objective 4.4)
1) Compilation succeeds and at run time an output of 0 and falseThe
default value for a boolean declared at class level is false, and integer is
0;
--------------------------------------------------------------------------------

Answer 29)
Objective 1.2)
1) Compile time error
You will get an error saying something like "Cant make a static reference to
a non static variable". Note that the main method is static. Even if main was
not static the array argv is local to the main method and would thus not be
visible within amethod.
--------------------------------------------------------------------------------

Answer 30)
Objective 5.2)
3) Output of "Not equal"
Despite the actual character strings matching, using the == operator will
simply compare memory location. Because the one string was created with the new
operator it will be in a different location in memory to the other string.
--------------------------------------------------------------------------------

Answer 31)
Objective 2.3)
4) Compile and run with output of "Pausing" and "Continuing" after a key is
hit
An overriden method in a sub class must not throw Exceptions not thrown in
the base class. In the case of the method amethod it throws no exceptions and
will thus compile without complain. There is no reason that a constructor cannot
be protected.
--------------------------------------------------------------------------------

Answer 32)
Objective 6.3)
4) Compile time error because of the line creating the instance of Inner
This looks like a question about inner classes but it is also a reference
to the fact that the main method is static and thus you cannot directly access a
non static method. The line causing the error could be fixed by changing it to
say Inner i = new Outer().new Inner();
Then the code would compile and run producing the output "Inner"
--------------------------------------------------------------------------------

Answer 33)
Objective 4.6)
1) Error at compile time
If you implement an interface you must create bodies for all methods in that
interface. This code will produce an error saying that MyWc must be declared
abstract because it does not define all of the methods in WindowListener. Option
4 is nonsense as comments can appear anywhere. Option 3 suggesting that it might
compile but not produce output is ment to mislead on the basis that what looks
like a constructor is actually an ordinary method as it has a return type.
--------------------------------------------------------------------------------

Answer 34)
Objective 1.2)
4) Compile time error
An error will be caused by attempting to define an integer as static within a
method. The lifetime of a field within a method is the duration of the running
of the method. A static field exists once only for the class. An approach like
this does work with Visual Basic.

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答