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

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

📁 非常好的java习题集
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<CODE>   public void printVal() </CODE>
<CODE>      {  System.out.println( "Super" );</CODE>
<CODE>      }</CODE>
<CODE>}</CODE>
<CODE>class Sub extends Super</CODE>
<CODE>{  int index = 2;</CODE>
<CODE>   public void printVal() </CODE>
<CODE>   {  System.out.println( "Sub" );</CODE>
<CODE>   }</CODE>
<CODE>}</CODE>
<CODE>public class Runner </CODE>
<CODE>{  public static void main( String argv[] ) </CODE>
<CODE>   {  Super sup = new Sub();</CODE>
<CODE>      System.out.print( sup.index + "," );</CODE>
<CODE>      sup.printVal();</CODE>
<CODE>   }</CODE>
<CODE>}</CODE></PRE>
<P>What will be printed to standard output?<BR><BR><INPUT type=radio value=a 
name=Q35>a) The code will not compile.<BR><INPUT type=radio value=b name=Q35>b) 
The code compiles and "5, Super" is printed to standard output.<BR><INPUT 
type=radio value=c name=Q35>c) The code compiles and "5, Sub" is printed to 
standard output.<BR><INPUT type=radio value=d name=Q35>d) The code compiles and 
"2, Super" is printed to standard output.<BR><INPUT type=radio value=e 
name=Q35>e) The code compiles and "2, Sub" is printed to standard 
output.<BR><INPUT type=radio value=f name=Q35>f) The code compiles, but throws 
an exception.<BR><BR><BR><FONT size=4>36. How many objects are eligible for 
garbage collection once execution has reached the line labeled Line 
A?<BR><BR></FONT><CODE>String name;<BR>String newName = "Nick";<BR>newName = 
"Jason";<BR>name = "Frieda";<BR><BR>String newestName = name;<BR><BR>name = 
null;<BR>//Line A<BR><BR></CODE><INPUT type=radio value=a name=Q36>a) 
0<BR><INPUT type=radio value=b name=Q36>b) 1<BR><INPUT type=radio value=c 
name=Q36>c) 2<BR><INPUT type=radio value=d name=Q36>d) 3<BR><INPUT type=radio 
value=e name=Q36>e) 4<BR><BR><BR><FONT size=4>37. Which of the following 
statements about Java's garbage collection are true?<BR><BR></FONT><INPUT 
type=checkbox value=CheckBox name=Q37_a> a) The garbage collector can be invoked 
explicitly using a Runtime object.<BR><INPUT type=checkbox value=CheckBox 
name=Q37_b> b) The finalize method is always called before an object is garbage 
collected.<BR><INPUT type=checkbox value=CheckBox name=Q37_c> c) Any class that 
includes a finalize method should invoke its superclass' finalize 
method.<BR><INPUT type=checkbox value=CheckBox name=Q37_d> d) Garbage collection 
behavior is very predictable.<BR><BR><BR><FONT size=4>38. What line of code 
would begin execution of a thread named myThread?<BR><BR></FONT><INPUT size=25 
name=Q38><FONT size=4><BR><BR><BR>39. Which methods are required to implement 
the interface Runnable.<BR><BR></FONT><INPUT type=checkbox value=CheckBox 
name=Q39_a><FONT size=4> </FONT>a) <TT>wait()</TT><FONT size=4><BR></FONT><INPUT 
type=checkbox value=CheckBox name=Q39_a> b)<TT> run()</TT><FONT 
size=4><BR></FONT><INPUT type=checkbox value=CheckBox name=Q39_a><FONT size=4> 
</FONT>c) <TT>stop()</TT><FONT size=4><BR></FONT><INPUT type=checkbox 
value=CheckBox name=Q39_a> d) <TT>update()</TT><FONT size=4><BR></FONT><INPUT 
type=checkbox value=CheckBox name=Q39_a><FONT size=4> </FONT>e) 
<TT>resume()</TT><FONT size=4><BR><BR><BR>40. What class defines the 
<TT>wait()</TT> method?<BR><BR></FONT><INPUT size=25 name=Q40><FONT 
size=4><BR><BR><BR>41. For what reasons might a thread stop 
execution?<BR><BR></FONT><INPUT type=checkbox name=Q41_a>a) A thread with higher 
priority began execution.<BR><INPUT type=checkbox name=Q41_b>b) The thread's 
<TT>wait()</TT> method was invoked.<BR><INPUT type=checkbox name=Q41_c>c) The 
thread invoked its <TT>yield()</TT> method.<BR><INPUT type=checkbox 
name=Q41_d>d) The thread's <TT>pause()</TT> method was invoked.<BR><INPUT 
type=checkbox name=Q41_e>e) The thread's <TT>sleep()</TT> method was 
invoked.<FONT size=4><BR><BR><BR>42. Which method below can change a String 
object, <TT>s</TT> ?<BR><BR></FONT><INPUT type=radio value=a name=Q42>a) 
<TT>equals( s )</TT><BR><INPUT type=radio value=b name=Q42>b) <TT>substring( s 
)</TT><BR><INPUT type=radio value=c name=Q42>c) <TT>concat( s )</TT><BR><INPUT 
type=radio value=d name=Q42>d) <TT>toUpperCase( s )</TT><BR><INPUT type=radio 
value=e name=Q42>e) none of the above will change <TT>s</TT><BR><BR><BR><FONT 
size=4>43. If <TT>s1</TT> is declared as: <BR><BR></FONT><CODE>String s1 = 
"phenobarbital";</CODE><BR><BR><FONT size=4>What will be the value of 
<TT>s2</TT> after the following line of code:</FONT> </P>
<BLOCKQUOTE>
  <P><CODE>String s2 =</CODE><FONT size=4><CODE> 
  </CODE></FONT><CODE>s1.substring( 3, 5 );</CODE> </P></BLOCKQUOTE>
<P><BR><INPUT type=radio value=a name=Q43>a) null<BR><INPUT type=radio value=b 
name=Q43>b) "eno"<BR><INPUT type=radio value=c name=Q43>c) "enoba"<BR><INPUT 
type=radio value=d name=Q43>d) "no"<BR><BR><BR><FONT size=4>44. What method(s) 
from the java.lang.Math class might <TT>method()</TT> be if the 
statement<BR><BR><TT>method( -4.4 ) == -4;<BR></TT><BR>is 
<TT>true</TT>.<BR><BR></FONT><INPUT type=checkbox value=CheckBox name=Q44_a> a) 
<TT>round()</TT><BR><INPUT type=checkbox value=CheckBox name=Q44_b> b) 
<TT>min()</TT><BR><INPUT type=checkbox value=CheckBox name=Q44_c> c) 
<TT>trunc()</TT><BR><INPUT type=checkbox value=CheckBox name=Q44_d> d) 
<TT>abs()</TT><BR><INPUT type=checkbox value=CheckBox name=Q44_e> e) 
<TT>floor()</TT><BR><INPUT type=checkbox value=CheckBox name=Q44_f> f) 
<TT>ceil()</TT><BR><BR><BR><FONT size=4>45. Which methods does java.lang.Math 
include for trigonometric computations?<BR><BR></FONT><INPUT type=checkbox 
value=CheckBox name=Q45_a><FONT size=4> </FONT>a) <TT>sin()</TT><BR><INPUT 
type=checkbox value=CheckBox name=Q45_a> b) <TT>cos()</TT><BR><INPUT 
type=checkbox value=CheckBox name=Q45_a> c) <TT>tan()</TT><BR><INPUT 
type=checkbox value=CheckBox name=Q45_a> d) <TT>aSin()</TT><BR><INPUT 
type=checkbox value=CheckBox name=Q45_a> e) <TT>aCos()</TT><BR><INPUT 
type=checkbox value=CheckBox name=Q45_a><FONT size=4> </FONT>f) 
<TT>aTan()</TT><BR><INPUT type=checkbox value=CheckBox name=Q45_a> g) 
<TT>toDegree()</TT><BR><BR><BR><FONT size=4>46. This piece of 
code:<BR><BR></FONT><CODE>TextArea ta = new TextArea( 10, 3 
);</CODE><BR><BR><FONT size=4>Produces (select all correct 
statements):<BR><BR></FONT><INPUT type=checkbox value=CheckBox name=Q46_a> a) a 
TextArea with 10 rows and up to 3 columns<BR><INPUT type=checkbox value=CheckBox 
name=Q46_b> b) a TextArea with a variable number of columns not less than 10 and 
3 rows<BR><INPUT type=checkbox value=CheckBox name=Q46_c> c) a TextArea that may 
not contain more than 30 characters<BR><INPUT type=checkbox value=CheckBox 
name=Q46_d> d) a TextArea that can be edited<BR><FONT size=4><BR><BR>47. In the 
list below, which subclass(es) of Component cannot be directly 
instantiated:<BR><BR></FONT><INPUT type=checkbox value=CheckBox name=Q47_a> a) 
Panel<BR><INPUT type=checkbox value=CheckBox name=Q47_b> b) Dialog<BR><INPUT 
type=checkbox value=CheckBox name=Q47_c> c) Container<BR><INPUT type=checkbox 
value=CheckBox name=Q47_d> d) Frame<BR><FONT size=4><BR><BR>48. Of the five 
Component methods listed below, only one is also a method of the class MenuItem. 
Which one?<BR><BR></FONT><INPUT type=radio value=a name=Q48>a) <TT>setVisible( 
boolean b )</TT><BR><INPUT type=radio value=b name=Q48>b) <TT>setEnabled( 
boolean b )</TT><BR><INPUT type=radio value=c name=Q48>c) 
<TT>getSize()</TT><BR><INPUT type=radio value=d name=Q48>d) <TT>setForeground( 
Color c )</TT><BR><INPUT type=radio value=e name=Q48>e) <TT>setBackground( Color 
c )</TT><BR><BR><BR><FONT size=4>49. If a font with variable width is used to 
construct the string text for a column, the initial size of the column 
is:<BR><BR></FONT><INPUT type=radio value=a name=Q49>a) determined by the number 
of characters in the string, multiplied by the width of a character in this 
font<BR><INPUT type=radio value=b name=Q49>b) determined by the number of 
characters in the string, multiplied by the average width of a character in this 
font<BR><INPUT type=radio value=c name=Q49>c) exclusively determined by the 
number of characters in the string<BR><INPUT type=radio value=d name=Q49>d) 
undetermined<BR><BR><BR><FONT size=4>50. Which of the following methods from 
the<TT> java.awt.Graphics</TT> class would be used to draw the outline of a 
rectangle with a single method <TT>call</TT>?<BR><BR></FONT><INPUT type=checkbox 
value=CheckBox name=Q50_a><FONT size=4> </FONT>a) <TT>fillRect()</TT><FONT 
size=4><BR></FONT><INPUT type=checkbox value=CheckBox name=Q50_b><FONT size=4> 
</FONT>b) <TT>drawRect()</TT><BR><INPUT type=checkbox value=CheckBox name=Q50_c> 
c) <TT>fillPolygon()</TT><BR><INPUT type=checkbox value=CheckBox name=Q50_d> d) 
<TT>drawPolygon()</TT><BR><INPUT type=checkbox value=CheckBox name=Q50_e> e) 
<TT>drawLine()</TT><FONT size=4><BR><BR><BR>51. The Container methods <TT>add( 
Component comp )</TT> and <TT>add( String name, Component comp )</TT> will throw 
an IllegalArgumentException if <TT>comp</TT> is a:<BR><BR></FONT><INPUT 
type=checkbox value=CheckBox name=Q51_a><FONT size=4> </FONT>a) button<BR><INPUT 
type=checkbox value=CheckBox name=Q51_b> b) list<BR><INPUT type=checkbox 
value=CheckBox name=Q51_c> c) window<BR><INPUT type=checkbox value=CheckBox 
name=Q51_d> d) textarea<BR><INPUT type=checkbox value=CheckBox name=Q51_e> e) 
container that contains this container<FONT size=4><BR><BR><BR>52. Of the 
following AWT classes, which one(s) are responsible for implementing the 
components layout?<BR><BR></FONT><INPUT type=checkbox value=CheckBox name=Q52_a> 
a) LayoutManager<BR><INPUT type=checkbox value=CheckBox name=Q52_b> b) 
GridBagLayout<BR><INPUT type=checkbox value=CheckBox name=Q52_c> c) 
ActionListener<BR><INPUT type=checkbox value=CheckBox name=Q52_d> d) 
WindowAdapter<BR><INPUT type=checkbox value=CheckBox name=Q52_e> e) 
FlowLayout<BR><FONT size=4><BR><BR>53. A component that should resize vertically 
but not horizontally should be placed in a:<BR><BR></FONT><INPUT type=checkbox 
value=CheckBox name=Q53_a><FONT size=4> </FONT>a) BorderLayout in the North or 
South location<BR><INPUT type=checkbox value=CheckBox name=Q53_b> b) FlowLayout 
as the first component<BR><INPUT type=checkbox value=CheckBox name=Q53_c> c) 
BorderLayout in the East or West location<BR><INPUT type=checkbox value=CheckBox 
name=Q53_d> d) BorderLayout in the Center location<BR><INPUT type=checkbox 
value=CheckBox name=Q53_e> e) GridLayout<FONT size=4><BR><BR><BR>54. What type 
of object is the parameter for all methods of the MouseListener 
interface?<BR><BR></FONT><INPUT size=25 name=Q54><FONT size=4><BR><BR><BR>55. 
Which of the following statements about event handling in JDK 1.1 and later are 
true?<BR><BR></FONT><INPUT type=checkbox name=Q55_a> a) A class can implement 
multiple listener interfaces<BR><INPUT type=checkbox name=Q55_b> b) If a class 
implements a listener interface, it only has to overload the methods it 
uses<BR><INPUT type=checkbox name=Q55_c> c) All of the MouseMotionAdapter class 
methods have a void return type.<BR><BR><BR><FONT size=4>56. Which of the 
following describe the sequence of method calls that result in a component being 
redrawn?<BR><BR></FONT><INPUT type=checkbox value=CheckBox name=Q56_a> a) 
invoke<TT> paint()</TT> directly<BR><INPUT type=checkbox value=CheckBox 
name=Q56_b> b) invoke update which calls <TT>paint()</TT><BR><INPUT 
type=checkbox value=CheckBox name=Q56_c> c) invoke <TT>repaint()</TT> which 
invokes <TT>update()</TT>, which in turn invokes <TT>paint()</TT><BR><INPUT 
type=checkbox value=CheckBox name=Q56_d> d) invoke <TT>repaint()</TT> which 
invokes paint directly<FONT size=4><BR><BR><BR>57. Choose all valid forms of the 
argument list for the <TT>FileOutputStream</TT> constructor shown 
below:<BR><BR></FONT><INPUT type=checkbox value=CheckBox name=Q57_a><FONT 
size=4> </FONT>a) <TT>FileOutputStream( FileDescriptor fd )</TT><BR><INPUT 
type=checkbox value=CheckBox name=Q57_b> b)<TT> FileOutputStream( String n, 
boolean a )<BR></TT><INPUT type=checkbox value=CheckBox name=Q57_c> c) 
<TT>FileOutputStream( boolean a )</TT><BR><INPUT type=checkbox value=CheckBox 
name=Q57_d> d) <TT>FileOutputStream()</TT><BR><INPUT type=checkbox 
value=CheckBox name=Q57_e> e) <TT>FileOutputStream( File f 
)</TT><BR><BR><BR><FONT size=4>58. A "mode" argument such as "r" or "rw" is 
required in the constructor for the class(es):<BR><BR></FONT><INPUT 
type=checkbox value=CheckBox name=Q58_a><FONT size=4> </FONT>a) 
DataInputStream<BR><INPUT type=checkbox value=CheckBox name=Q58_b> b) 
InputStream<BR><INPUT type=checkbox value=CheckBox name=Q58_c> c) 
RandomAccessFile<BR><INPUT type=checkbox value=CheckBox name=Q58_d> d) 
File<BR><INPUT type=checkbox value=CheckBox name=Q58_e> e) None of the 
above<BR><BR><BR><FONT size=4>59. A directory can be created using a method from 
the class(es):<BR><BR></FONT><INPUT type=checkbox value=CheckBox 
name=Q59_a><FONT size=4> </FONT>a) File<BR><INPUT type=checkbox value=CheckBox 
name=Q59_b> b) DataOutput<BR><INPUT type=checkbox value=CheckBox name=Q59_c> c) 
Directory<BR><INPUT type=checkbox value=CheckBox name=Q59_d> d) 
FileDescriptor<BR><INPUT type=checkbox value=CheckBox name=Q59_e> e) 
FileOutputStream<BR><BR><FONT size=4><BR>60. If <TT>raf</TT> is a 
RandomAccessFile, what is the result of compiling and executing the following 
code?<BR></FONT><CODE><BR>raf.seek( raf.length() );<BR></CODE><FONT 
size=4><BR></FONT><INPUT type=radio value=a name=Q60> a) The code will not 
compile.<BR><INPUT type=radio value=b name=Q60> b) An IOException will be 
thrown.<BR><INPUT type=radio value=c name=Q60> c) The file pointer will be 
positioned immediately before the last character of the file.<BR><INPUT 
type=radio value=d name=Q60> d) The file pointer will be positioned immediately 
after the last character of the file.</P>
<P>
<HR SIZE=4>

<P></P>
<P><B>Note:</B> Check your own answers before hitting the <B>Check</B> button 
below. When you click the <B>Check</B> button, a browser window will appear that 
contains a summary of your results. When the answer window appears, 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=submit value="Check My Test"> <INPUT type=reset value="Clear Answers"></P>
<P><BR><FONT face=Helvetica,Palatino,Arial size=1>

⌨️ 快捷键说明

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