📄 scjp-1.htm
字号:
<OL type=a>
<LI>Illegal at compile time
<LI>Legal at compile time but possibly illegal at runtime
<LI>Definitely legal at runtime </LI></OL>
<P><B>Question 21</B>: How you can use the escape notation \u to set the
variable <FONT face=Courier>c</FONT>, declared as a <FONT
face=Courier>char</FONT>, to the Unicode character whose value is hex
0x30A0?
<P>Fill in the blank.
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT
face=Courier> </FONT></TD></TR></TBODY></TABLE>
<P>
<P><B>Question 22</B>: Which operators are overloaded for String objects?
<P>
<P><B><A name=no20>Question 20</A></B>: Given these class definitions:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>class Superclass { }</FONT>
<P><FONT face=Courier>class Subclass1 extends Superclass { }</FONT>
<P><FONT face=Courier>class Subclass2 extends Superclass {
}</FONT></P></TD></TR></TBODY></TABLE>and these objects:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>Superclass a = new
Superclass();</FONT>
<P><FONT face=Courier>Subclass1 b = new Subclass1();</FONT>
<P><FONT face=Courier>Subclass2 c = new
Subclass2();</FONT></P></TD></TR></TBODY></TABLE>which of the following
explains the result of the statement:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>b =
(Subclass1)c;</FONT></TD></TR></TBODY></TABLE>Select the one right answer.
<P>
<OL type=a>
<LI>Illegal at compile time
<LI>Legal at compile time but possibly illegal at runtime
<LI>Definitely legal at runtime </LI></OL>
<P><B>Question 21</B>: How you can use the escape notation \u to set the
variable <FONT face=Courier>c</FONT>, declared as a <FONT
face=Courier>char</FONT>, to the Unicode character whose value is hex
0x30A0?
<P>Fill in the blank.
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT
face=Courier> </FONT></TD></TR></TBODY></TABLE><B>Question 22</B>:
Which operators are overloaded for String objects?
<P>Select all valid answers.
<P>
<OL type=a>
<LI><FONT face=Courier>-</FONT>
<LI><FONT face=Courier>+=</FONT>
<LI><FONT face=Courier>>></FONT>
<LI><FONT face=Courier>&</FONT> </LI></OL>
<LI>none of these
<P><B>Question 23</B>: How can you change the <FONT
face=Courier>break</FONT> statement below so that it breaks out of both
the inner and middle loops and continues with the next iteration of the
outer loop?
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>outer: for (int x = 0; x <
3; x++) {</FONT>
<DIR><FONT face=Courier>middle: for (int y = 0; y < 3; y++)
{</FONT>
<DIR><FONT face=Courier>inner: for (int z = 0; z < 3; z++)
{</FONT>
<DIR><FONT face=Courier>if (arr(x, y, z) == targetValue)</FONT>
<DIR><FONT face=Courier>break;</FONT></DIR></DIR><FONT
face=Courier>}</FONT></DIR><FONT face=Courier>}</FONT></DIR><FONT
face=Courier>}</FONT></TD></TR></TBODY></TABLE>Select the one right
answer.
<P>
<OL type=a>
<LI>break inner;
<LI>break middle;
<LI>break outer;
<LI>continue;
<LI>continue middle; </LI></OL>
<P>
<P><B>Question 24</B>: Given this code snippet:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>try {</FONT>
<DIR><FONT face=Courier>tryThis();</FONT>
<P><FONT face=Courier>return;</FONT></P></DIR><FONT face=Courier>}
catch (IOException x1) {</FONT>
<DIR><FONT face=Courier>System.out.println("exception 1");</FONT>
<P><FONT face=Courier>return;</FONT></P></DIR><FONT face=Courier>}
catch (Exception x2) {</FONT>
<DIR><FONT face=Courier>System.out.println("exception 2");</FONT>
<P><FONT face=Courier>return;</FONT></P></DIR><FONT face=Courier>}
finally {</FONT>
<DIR><FONT
face=Courier>System.out.println("finally");</FONT></DIR><FONT
face=Courier>}</FONT></TD></TR></TBODY></TABLE>What will appear in the
standard output if <FONT face=Courier>tryThis()</FONT> throws a
NumberFormatException?
<P>Select the one right answer.
<P>
<OL type=a>
<LI>Nothing
<LI>"exception 1", followed by "finally"
<LI>"exception 2", followed by "finally"
<LI>"exception 1"
<LI>"exception 2" </LI></OL>
<P>
<P><B>Question 25</B>: Given these class definitions:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>class Superclass { }</FONT>
<P><FONT face=Courier>class Subclass1 extends Superclass {
}</FONT></P></TD></TR></TBODY></TABLE>and these objects:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>Superclass a = new
Superclass();</FONT>
<P><FONT face=Courier>Subclass1 b = new
Subclass1();</FONT></P></TD></TR></TBODY></TABLE>which of the following
explains the result of the statement:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>b =
a;</FONT></TD></TR></TBODY></TABLE>Select the one right answer.
<P>
<OL type=a>
<LI>Illegal at compile time
<LI>Legal at compile time but possibly illegal at runtime
<LI>Definitely legal at runtime </LI></OL>
<P><B>Question 26</B>: Given these class definitions:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>class Superclass { }</FONT>
<P><FONT face=Courier>class Subclass1 extends Superclass {
}</FONT></P></TD></TR></TBODY></TABLE>and these objects:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>Superclass a = new
Superclass();</FONT>
<P><FONT face=Courier>Subclass1 b = new
Subclass1();</FONT></P></TD></TR></TBODY></TABLE>which of the following
explains the result of the statement:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>b =
(Subclass1)a;</FONT></TD></TR></TBODY></TABLE>Select the one right answer.
<P>
<OL type=a>
<LI>Illegal at compile time
<LI>Legal at compile time but possibly illegal at runtime
<LI>Definitely legal at runtime </LI></OL>
<P><B>Question 27</B>: To invoke <FONT face=Courier>read()</FONT> from an
InputStream subclass, you must handle what type of exception?
<DIR>Fill in the blank.
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT
face=Courier> </FONT></TD></TR></TBODY></TABLE> </DIR><B>Question
28</B>: Imagine there are two exception classes called Exception1 and
Exception2 that descend from the Exception class. Given these two class
definitions:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>class First {</FONT>
<DIR><FONT face=Courier>void test() throws Exception1, Exception2 {
. . . }</FONT></DIR><FONT face=Courier>}</FONT>
<P><FONT face=Courier>class Second extends First {</FONT>
<DIR><FONT face=Courier>void test() { . . . }</FONT></DIR><FONT
face=Courier>}</FONT></TD></TR></TBODY></TABLE>Create a class called Third
that extends Second and defines a <FONT face=Courier>test()</FONT> method.
What exceptions can Third抯 <FONT face=Courier>test()</FONT> method throw?
<P>Select all valid answers.
<P>
<OL type=a>
<LI>Exception1
<LI>Exception2
<LI>no checked exceptions
<LI>any exceptions declared in the <FONT face=Courier>throws</FONT>
clause of the Third抯 <FONT face=Courier>test()</FONT> method. </LI></OL>
<P>
<P><B>Question 29</B>: What is the result of executing the following code:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>class Test {</FONT>
<DIR><FONT face=Courier>public static void main(String[] args)
{</FONT>
<DIR><FONT face=Courier>Test t = new Test();</FONT>
<P><FONT face=Courier>t.test(1.0, 2L, 3);</FONT></P></DIR><FONT
face=Courier>}</FONT>
<P><FONT face=Courier>void test(double a, double b, short c)
{</FONT>
<DIR><FONT face=Courier>System.out.println("1");</FONT></DIR><FONT
face=Courier>}</FONT>
<P><FONT face=Courier>void test(float a, byte b, byte c) {</FONT>
<DIR><FONT face=Courier>System.out.println("2");</FONT></DIR><FONT
face=Courier>}</FONT>
<P><FONT face=Courier>void test(double a, double b, double c)
{</FONT>
<DIR><FONT face=Courier>System.out.println("3");</FONT></DIR><FONT
face=Courier>}</FONT>
<P><FONT face=Courier>void test(int a, long b, int c) {</FONT>
<DIR><FONT face=Courier>System.out.println("4");</FONT></DIR><FONT
face=Courier>}</FONT>
<P><FONT face=Courier>void test(long a, long b, long c) {</FONT>
<DIR><FONT face=Courier>System.out.println("5");</FONT></DIR><FONT
face=Courier>}</FONT></DIR><FONT
face=Courier>}</FONT></TD></TR></TBODY></TABLE>Select the one right
answer.
<P>
<OL type=a>
<LI>1
<LI>2
<LI>3
<LI>4
<LI>5 </LI></OL>
<P>
<P><B>Question 30</B>: Given this code snippet:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>double a = 90.7;</FONT>
<P><FONT face=Courier>double b = method(a);</FONT>
<P><FONT
face=Courier>System.out.println(b);</FONT></P></TD></TR></TBODY></TABLE>If
this snippet displays <FONT face=Courier>90</FONT> in the standard output,
what Math method did <FONT face=Courier>method()</FONT> invoke?
<P>Select all valid answers.
<P>
<OL type=a>
<LI><FONT face=Courier>abs()</FONT>
<LI><FONT face=Courier>min()</FONT>
<LI><FONT face=Courier>floor()</FONT>
<LI><FONT face=Courier>round()</FONT>
<LI><FONT face=Courier>ceil()</FONT> </LI></OL>
<P><B>Question 31</B>: In Java 1.0.2, to make a Button object
non-responsive to mouse clicks, you can invoke which method? (Only supply
the method name, without a parameter list.)
<P>Fill in the blank.
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT
face=Courier> </FONT></TD></TR></TBODY></TABLE><B>Question 32</B>:
Given this code snippet:
<TABLE width="100%" border=1>
<TBODY>
<TR>
<TD vAlign=center><FONT face=Courier>double a = 14.9;</FONT>
<P><FONT face=Courier>double b = method(a);</FONT>
<P><FONT
face=Courier>System.out.println(b);</FONT></P></TD></TR></TBODY></TABLE>If
this snippet displays 15 in the standard output, what Math method(s) could
<FONT face=Courier>method()</FONT> have invoke?
<P>Select the one right answer.
<P>
<OL type=a>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -