⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mindq's sun certified java programmer practice test.htm

📁 非常好的java习题集
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<META content="MSHTML 6.00.2462.0" name=GENERATOR></HEAD>
<BODY vLink=#006699 aLink=#006699 link=#006699 bgColor=white><IMG height=65 
src="" width=163> 
<FORM name=quiz onsubmit="return compute(quiz)" method=post>
<P>&nbsp;</P>
<CENTER>
<P><FONT size=5><B>MindQ's</B> <B>Sun Certified Java Programmer Practice 
Test</B></FONT></P>
<P>Updated 4/7/99</P>
<P>
<HR width=580>

<P></P></CENTER>
<P><BR>Name: <INPUT size=25 name=email><BR><BR>Instructions: Answer the 
questions below to the best of your ability. When you finish the test, click the 
<B>Check</B> button at the bottom to view the results. When the answer window 
appears (after you have taken the test and clicked the <B>Check</B> button), you 
may use the <B>File</B> menu to print the page or save the results as a plain 
text or html document.</P>
<P><INPUT type=hidden size=-1 
value="Sun Certified Java Programmer Practice Test" name=pretest_label> 
<HR>
<A name=section1></A><BR><BR><FONT size=4>1. Which of the following are valid 
definitions of an application's main( ) method?<BR><BR></FONT><INPUT 
type=checkbox value=CheckBox name=Q1_a>a) <TT>public static void 
main();</TT><BR><INPUT type=checkbox value=CheckBox name=Q1_b>b) <TT>public 
static void main( String args );</TT><BR><INPUT type=checkbox value=CheckBox 
name=Q1_c>c) <TT>public static void main( String args[] );</TT><BR><INPUT 
type=checkbox value=CheckBox name=Q1_d>d) <TT>public static void main( Graphics 
g );</TT><BR><INPUT type=checkbox value=CheckBox name=Q1_e>e) <TT>public static 
boolean main( String args[] );</TT><BR><BR><BR><FONT size=4>2. If MyProg.java 
were compiled as an application and then run from the command line as:</FONT> 
<P></P><PRE><CODE>              java MyProg I like tests</CODE></PRE>
<P><FONT size=4>what would be the value of args[ 1 ] inside the main( ) 
method?<BR><BR></FONT><INPUT type=radio value=a name=Q2>a) MyProg<BR><INPUT 
type=radio value=b name=Q2>b) "I"<BR><INPUT type=radio value=c name=Q2>c) 
"like"<BR><INPUT type=radio value=d name=Q2>d) 3<BR><INPUT type=radio value=e 
name=Q2>e) 4<BR><INPUT type=radio value=f name=Q2>f) null until a value is 
assigned<BR><BR><BR><FONT size=4>3. Which of the following are Java 
keywords?<BR><BR></FONT><INPUT type=checkbox value=CheckBox name=Q3_a>a) 
array<BR><INPUT type=checkbox value=CheckBox name=Q3_b>b) boolean<BR><INPUT 
type=checkbox value=CheckBox name=Q3_c>c) Integer<BR><INPUT type=checkbox 
value=CheckBox name=Q3_d>d) protect<BR><INPUT type=checkbox value=CheckBox 
name=Q3_e>e) super<BR><BR><BR><FONT size=4>4. After the declaration:</FONT> </P>
<BLOCKQUOTE>
  <P><TT>char[] c = new char[100];</TT> </P></BLOCKQUOTE>
<P><FONT size=4>what is the value of c[50]?<BR><BR></FONT><INPUT type=radio 
value=a name=Q4>a) 50<BR><INPUT type=radio value=b name=Q4>b) 49<BR><INPUT 
type=radio value=c name=Q4>c) '\u0000'<BR><INPUT type=radio value=d name=Q4>d) 
'\u0020'<BR><INPUT type=radio value=e name=Q4>e) " "<BR><INPUT type=radio 
value=f name=Q4>f) cannot be determined<BR><INPUT type=radio value=g name=Q4>g) 
always null until a value is assigned<BR><BR><BR><FONT size=4>5. After the 
declaration:</FONT> </P>
<BLOCKQUOTE>
  <P><TT>int x;</TT> </P></BLOCKQUOTE>
<P><FONT size=4>the range of <TT>x</TT> is:<BR><BR></FONT><INPUT type=radio 
value=a name=Q5>a) -2<SUP>31</SUP> to 2<SUP>31</SUP>-1 <BR><INPUT type=radio 
value=b name=Q5>b) -2<SUP>16</SUP> to 2<SUP>16</SUP> - 1 <BR><INPUT type=radio 
value=c name=Q5>c) -2<SUP>32</SUP> to 2<SUP>32</SUP> <BR><INPUT type=radio 
value=d name=Q5>d) -2<SUP>16</SUP> to 2<SUP>16</SUP><BR><INPUT type=radio 
value=e name=Q5>e) cannot be determined; it depends on the 
machine<BR><BR><BR><FONT size=4>6. Which identifiers are 
valid?<BR><BR></FONT><INPUT type=checkbox name=Q6_a> a) 
<TT>_xpoints</TT><BR><INPUT type=checkbox name=Q6_b> b) <TT>r2d2</TT><BR><INPUT 
type=checkbox name=Q6_c> c) <TT>bBb$</TT><BR><INPUT type=checkbox name=Q6_d> d) 
<TT>set-flow</TT><BR><INPUT type=checkbox name=Q6_e> e) 
<TT>thisisCrazy</TT><BR><BR><BR><FONT size=4>7. Represent the number 6 as a 
hexadecimal literal.<BR><BR></FONT><INPUT size=5 name=Q7><FONT 
size=4><BR><BR><BR>8. Which of the following statements assigns "Hello Java" to 
the String variable <TT>s</TT>?<BR><BR></FONT><INPUT type=checkbox 
value=CheckBox name=Q7_a><FONT size=4> </FONT>a) <TT>String s = "Hello 
Java";</TT><BR><INPUT type=checkbox value=CheckBox name=Q7_b> b) <TT>String s[] 
= "Hello Java";</TT><BR><INPUT type=checkbox value=CheckBox name=Q7_c> c) 
<TT>new String s = "Hello Java";</TT><BR><INPUT type=checkbox value=CheckBox 
name=Q7_d> d) <TT>String s = new String("Hello Java");</TT><BR><BR><BR><FONT 
size=4>9. An integer, x has a binary value (using 1 byte) of 10011100. What is 
the binary value of z after these statements:</FONT> </P>
<BLOCKQUOTE>
  <P><TT>int y = 1 &lt;&lt; 7;<BR>int z = x &amp; y;</TT> </P></BLOCKQUOTE>
<P><BR><INPUT type=radio value=a name=Q9>a) 1000 0001<BR><INPUT type=radio 
value=b name=Q9>b) 1000 0000<BR><INPUT type=radio value=c name=Q9>c) 0000 
0001<BR><INPUT type=radio value=d name=Q9>d) 1001 1101<BR><INPUT type=radio 
value=e name=Q9>e) 1001 1100<BR><BR><BR><FONT size=4>10. Which statements are 
accurate:<BR><BR></FONT><INPUT type=checkbox value=CheckBox name=Q10_a> a) 
&gt;&gt; performs signed shift while &gt;&gt;&gt; performs an unsigned 
shift.<BR><INPUT type=checkbox value=CheckBox name=Q10_b> b) &gt;&gt;&gt; 
performs a signed shift while &gt;&gt; performs an unsigned shift.<BR><INPUT 
type=checkbox value=CheckBox name=Q10_c> c) &lt;&lt; performs a signed shift 
while &lt;&lt;&lt; performs an insigned shift.<BR><INPUT type=checkbox 
value=CheckBox name=Q10_d> d) &lt;&lt;&lt; performs a signed shift while 
&lt;&lt; performs an unsigned shift.<BR><BR><BR><FONT size=4>11. The statement 
...</FONT> </P>
<BLOCKQUOTE>
  <P><TT>String s = "Hello" + "Java";</TT> </P></BLOCKQUOTE>
<P><FONT size=4>yields the same value for s as ...</FONT> </P>
<BLOCKQUOTE>
  <P><TT>String s = "Hello";<BR>String s2= "Java";<BR>s.concat( s2 );</TT> 
</P></BLOCKQUOTE>
<P><INPUT type=radio value=true name=Q11>True<BR><INPUT type=radio value=false 
name=Q11>False<BR><BR><BR><FONT size=4>12. If you compile and execute an 
application with the following code in its <TT>main()</TT> method:</FONT></P><PRE>	String s = new String( "Computer" );
	
	if( s == "Computer" )
		System.out.println( "Equal A" );
	if( s.equals( "Computer" ) )
		System.out.println( "Equal B" );</PRE>
<P><INPUT type=radio value=a name=Q12>a) It will not compile because the String 
class does not support the = = operator.<BR><INPUT type=radio value=b 
name=Q12>b) It will compile and run, but nothing is printed.<BR><INPUT 
type=radio value=c name=Q12>c) "Equal A" is the only thing that is 
printed.<BR><INPUT type=radio value=d name=Q12>d) "Equal B" is the only thing 
that is printed.<BR><INPUT type=radio value=e name=Q12>e) Both "Equal A" and 
"Equal B" are printed.<BR><BR><BR><FONT size=4>13. Consider the two 
statements:</FONT></P><PRE>	1. boolean passingScore = false &amp;&amp; grade == 70;
	2. boolean passingScore = false &amp; grade == 70;</PRE>
<P><FONT size=4>The expression</FONT> </P>
<BLOCKQUOTE>
  <P><TT>grade == 70</TT> </P></BLOCKQUOTE>
<P><FONT size=4>is evaluated:<BR></FONT><BR><INPUT type=radio value=a 
name=Q13>a) in both 1 and 2<BR><INPUT type=radio value=b name=Q13>b) in neither 
1 nor 2<BR><INPUT type=radio value=c name=Q13>c) in 1 but not 2<BR><INPUT 
type=radio value=d name=Q13>d) in 2 but not 1<BR><INPUT type=radio value=e 
name=Q13>e) invalid because false should be FALSE<BR><BR><BR><FONT size=4>14. 
Given the variable declarations below:</FONT> </P>
<BLOCKQUOTE>
  <P><TT>byte myByte;<BR>int myInt;<BR>long myLong;<BR>char myChar;<BR>float 
  myFloat;<BR>double myDouble;</TT> </P></BLOCKQUOTE>
<P><FONT size=4>Which one of the following assignments would need an explicit 
cast?<BR></FONT><BR><INPUT type=checkbox name=Q14_a>a) <TT>myInt = 
myByte;</TT><BR><INPUT type=checkbox name=Q14_b>b) <TT>myInt = 
myLong;</TT><BR><INPUT type=checkbox name=Q14_c>c) <TT>myByte = 
3;</TT><BR><INPUT type=checkbox name=Q14_d>d) <TT>myInt = myChar;</TT><BR><INPUT 
type=checkbox name=Q14_e>e) <TT>myFloat = myDouble;</TT><BR><INPUT type=checkbox 
name=Q14_f>f) <TT>myFloat = 3;</TT><BR><INPUT type=checkbox name=Q14_g>g) 
<TT>myDouble = 3.0;</TT><BR><BR><BR><BR><FONT size=4>15. Consider this class 
example:</FONT></P><PRE><TT>class MyPoint </TT>
<TT>{  void myMethod() </TT>
<TT>   {  int x, y;</TT>
<TT>      x = 5; y = 3;</TT>
<TT>      System.out.print( " ( " + x + ", " + y + " ) " );</TT>
<TT>      switchCoords( x, y );</TT>
<TT>      System.out.print( " ( " + x + ", " + y + " ) " );</TT>
<TT>   }</TT>
<TT>   void switchCoords( int x, int y ) </TT>
<TT>   {  int temp;</TT>
<TT>      temp = x;</TT>
<TT>      x = y;</TT>
<TT>      y = temp;</TT>
<TT>      System.out.print( " ( " + x + ", " + y + " ) " );</TT>
<TT>   }</TT>
<TT>}</TT></PRE>
<P><FONT size=4>What is printed to standard output if <TT>myMethod()</TT> is 
executed?<BR></FONT><BR><INPUT type=radio value=a name=Q15>a) (5, 3) (5, 3) (5, 
3)<BR><INPUT type=radio value=b name=Q15>b) (5, 3) (3, 5) (3, 5)<BR><INPUT 
type=radio value=c name=Q15>c) (5, 3) (3, 5) (5, 3)<BR><FONT 
size=2><BR><BR></FONT><FONT size=4>16. To declare an array of 31 floating point 
numbers representing snowfall for each day of March in Gnome, Alaska, which 
declarations would be valid?<BR><BR></FONT><INPUT type=checkbox name=Q16_a> a) 
<TT>double snow[] = new double[31];</TT><BR><INPUT type=checkbox name=Q16_b> b) 
<TT>double snow[31] = new array[31];</TT><BR><INPUT type=checkbox name=Q16_c> c) 
<TT>double snow[31] = new array;</TT><BR><INPUT type=checkbox name=Q16_d> d) 
<TT>double[] snow = new double[31];</TT><BR><BR><BR><FONT size=4>17. If 
<TT>arr[]</TT> contains only positive integer values, what does this function 
do?</FONT></P><PRE><CODE>public int guessWhat( int arr[] )</CODE>
<CODE>{  int x= 0;</CODE>
<CODE>   for( int i = 0; i &lt; arr.length; i++ )</CODE>
<CODE>      x = x &lt; arr[i] ? arr[i] : x;</CODE>
<CODE>   return x;</CODE>
<CODE>}</CODE></PRE>
<P><INPUT type=radio value=a name=Q17>a) Returns the index of the highest 
element in the array<CODE><BR></CODE><INPUT type=radio value=b name=Q17>b) 
Returns true/false if there are any elements that repeat in the array<BR><INPUT 
type=radio value=c name=Q17>c) Returns how many even numbers are in the 
array<BR><INPUT type=radio value=d name=Q17>d) Returns the highest element in 
the array<BR><INPUT type=radio value=e name=Q17>e) Returns the number of 
question marks in the array<BR><BR><BR><FONT size=4>18. Consider the code 
below:</FONT> </P>
<BLOCKQUOTE>
  <P><TT>arr[0] = new int[4];<BR>arr[1] = new int[3];<BR>arr[2] = new 
  int[2];<BR>arr[3] = new int[1];<BR>for( int n = 0; n &lt; 4; n++ 
  )<BR>System.out.println( /* what goes here? */</TT> ); </P></BLOCKQUOTE>
<P><FONT size=4>Which statement below, when inserted as the body of the for 
loop, would print the number of values in each row?</FONT><BR><BR><INPUT 
type=radio value=a name=Q18>a) <TT>arr[n].length();</TT><BR><INPUT type=radio 
value=b name=Q18>b) <TT>arr.size;</TT><BR><INPUT type=radio value=c name=Q18>c) 
<TT>arr.size -1;</TT><BR><INPUT type=radio value=d name=Q18>d) 
<TT>arr[n][size];</TT><BR><INPUT type=radio value=e name=Q18>e) 
<TT>arr[n].length;</TT><BR><BR><BR><FONT size=4>19. If size = 4, 
<TT>triArray</TT> looks like:</FONT></P><PRE><BLOCKQUOTE>
<CODE>int[][] makeArray( int size) </CODE>
<CODE>{  int[][] triArray = new int[size] [];</CODE>
<CODE>   int val=1;</CODE>
<CODE>   for( int i = 0; i &lt; triArray.length; i++ ) </CODE>
<CODE>   {  triArray[i] = new int[i+1];</CODE>
<CODE>	  for( int j=0; j &lt; triArray[i].length; j++ )</CODE>
<CODE>      {  triArray[i][j] = val++;</CODE>
<CODE>      }</CODE>
<CODE>   }</CODE>
<CODE>   return triArray;</CODE>
<CODE>}</CODE></BLOCKQUOTE>
</PRE>
<P>
<TABLE width="100%" border=0>
  <TBODY>
  <TR>
    <TD vAlign=top width="20%"><INPUT type=radio value=a name=Q19>a) <BR>1 2 3 
      4<BR>5 6 7<BR>8 9<BR>10</TD>
    <TD vAlign=top width="20%"><INPUT type=radio value=b name=Q19>b) <BR>1 4 9 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -