SCJP试题-SCJPMockExam3

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



Answers
--------------------------------------------------------------------------------

Answer 1)
Objective 1.2)
1) The code will compile and run, printing out the words "My Func"
A class that contains an abstract method must be declared abstract itself,
but may contain non abstract methods.
--------------------------------------------------------------------------------

Answer 2)
Objective 4.1)
4) The code will compile but will complain at run time that main is not
correctly defined
In this example the parameter is a string not a string array as needed for
the correct main method
--------------------------------------------------------------------------------

Answer 3)
Objective 4.3)
1) public2) private4) transient
The keyword transient is easy to forget as is not frequently used. Although a
method may be considered to be friendly like in C++ it is not a Java
keyword.
--------------------------------------------------------------------------------

Answer 4)
Objective 1.2)
2) The compiler will complain that the Base class is not declared as
abstract.
If a class contains abstract methods it must itself be declared as
abstract
--------------------------------------------------------------------------------

Answer 5)
Objective 1.2)
1) To get to access hardware that Java does not know about3) To write
optimised code for performance in a language such as C/C++
--------------------------------------------------------------------------------

Answer 6)
Objective 1.2)
4) Success in compilation and output of "amethod" at run time.
A final method cannot be ovverriden in a sub class, but apart from that it
does not cause any other restrictions.
--------------------------------------------------------------------------------

Answer 7)
Objective 1.2)
4) Compilation and execution without error
It would cause a run time error if you had a call to amethod though.
--------------------------------------------------------------------------------

Answer 8)
Objective 1.2)
1)Compile time error: Base cannot be private
A top leve (non nested) class cannot be private.
--------------------------------------------------------------------------------

Answer 9)
Objective 1.2)
4) P1 compiles cleanly but P2 has an error at compile time
The package statement in P1.java is the equivalent of placing the file in a
different directory to the file P2.java and thus when the compiler tries to
compile P2 an error occurs indicating that superclass P1 cannot be found.
--------------------------------------------------------------------------------

Answer 10)
Objective 1.1)
2) An error at run time
This code will compile, but at run-time you will get an ArrayIndexOutOfBounds
exception. This becuase counting in Java starts from 0 and so the 5th element of
this array would be i[4].
Remember that arrays will always be initialized to default values wherever
they are created.
--------------------------------------------------------------------------------

Answer 11)
Objective 1.1)
2)myarray.length;
The String class has a length() method to return the number of characters. I
have sometimes become confused between the two.
--------------------------------------------------------------------------------

Answer 12)
Objective 8.2)
3) A Frame with one large button marked Four in the Centre
The default layout manager for a Frame is the BorderLayout manager. This
Layout manager defaults to placing components in the centre if no constraint is
passed with the call to the add method.
--------------------------------------------------------------------------------

Answer 13)
Objective 8.2)
4) Do nothing, the FlowLayout will position the component
--------------------------------------------------------------------------------

Answer 14)
Objective 8.2)
1) Use the setLayout method

视频学习

我考网版权与免责声明

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

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

最近更新

社区交流

考试问答