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

📄 中文java技术网scjp考试题310-025(第二套2)18-50-147.htm

📁 这是多次JAVA考试试题或模拟试题集锦
💻 HTM
📖 第 1 页 / 共 2 页
字号:
Which is a method of the MouseMotionListener interface?<br />
A. Public void mouseMoved(MouseEvent)<br />
B. Public boolean mouseMoved(MouseEvent)<br />
C. Public void mouseMoved(MouseMotionEvent)<br />
D. Public boolean MouseMoved(MouseMotionEvent)<br />
E. Public boolean mouseMoved(MouseMotionEvent)<br />
Answer: A<br />
Question No 34<br />
Exhibit:<br />
1. import java.awt*;<br />
2.<br />
3. public class X extends Frame (<br />
4. public static void main(string []args) (<br />
5. X x = new X ();<br />
6. X.pack();<br />
7. x.setVisible(true);<br />
8. )<br />
9.<br />
10. public X () (<br />
11. setlayout (new GridLayout (2,2));<br />
12.<br />
13. Panel p1 = new panel();<br />
14. Add(p1);<br />
15. Button b1= new Button (“One”);<br />
16. P1.add(b1);<br />
17.<br />
18. Panel p2 = new panel();<br />
19. Add(p2);<br />
20. Button b2= new Button (“Two”);<br />
21. P2.add(b2);<br />
22.<br />
23. Button b3= new Button (“Three”);<br />
24. add(b3);<br />
25.<br />
26. Button b4= new Button (“Four”);<br />
27. add(b4);<br />
28. )<br />
29. )<br />
Which two statements are true? (Choose Two)<br />
A. All the buttons change height if the frame height is resized.<br />
B. All the buttons change width if the Frame width is resized.<br />
C. The size of the button labeled “One” is constant even if the Frame is resized.<br />
D. Both width and height of the button labeled “Three” might change if the Frame is resized.<br />
Answer: C, D<br />
Question No 35<br />
You are assigned the task of building a panel containing a TextArea at the top, a label directly below it,<br />
and a button directly below the label. If the three components are added directly to the panel. Which<br />
layout manager can the panel use to ensure that the TextArea absorbs all of the free vertical space when<br />
the panel is resized?<br />
A. GridLayout.<br />
B. CardLayout.<br />
C. FlowLayout.<br />
D. BorderLayout.<br />
E. GridBagLayout.<br />
Answer: E<br />
Question No 36<br />
Which gets the name of the parent directory file “file.txt”?<br />
A. String name= File.getParentName(“file.txt”);<br />
B. String name= (new File(“file.txt”)).getParent();<br />
C. String name = (new File(“file.txt”)).getParentName();<br />
D. String name= (new File(“file.txt”)).getParentFile();<br />
E. Directory dir=(new File (“file.txt”)).getParentDir();<br />
String name= dir.getName();<br />
Answer: B<br />
Question No 37<br />
Which can be used to encode charS for output?<br />
A. Java.io.OutputStream.<br />
B. Java.io.OutputStreamWriter.<br />
C. Java.io.EncodeOutputStream.<br />
D. Java.io.EncodeWriter.<br />
E. Java.io.BufferedOutputStream.<br />
Answer: B<br />
<br />
Question No 38<br />
The file “file.txt” exists on the file system and contsins ASCII text.<br />
Given:<br />
38. try {<br />
39. File f = new File(“file.txt”);<br />
40. OutputStream out = new FileOutputStream(f, true);<br />
41. }<br />
42. catch (IOException) {}<br />
What is the result?<br />
A. The code does not compile.<br />
B. The code runs and no change is made to the file.<br />
C. The code runs and sets the length of the file to 0.<br />
D. An exception is thrown because the file is not closed.<br />
E. The code runs and deletes the file from the file system.<br />
Answer: A<br />
Question No 39<br />
Which constructs a DataOutputStream?<br />
A. New dataOutputStream(“out.txt”);<br />
B. New dataOutputStream(new file(“out.txt”));<br />
C. New dataOutputStream(new writer(“out.txt”));<br />
D. New dataOutputStream(new FileWriter(“out.txt”));<br />
E. New dataOutputStream(new OutputStream(“out.txt”));<br />
F. New dataOutputStream(new FileOutputStream(“out.txt”));<br />
Answer: F<br />
Question No 40<br />
What writes the text “<end>” to the end of the file “file.txt”?<br />
A. OutputStream out= new FileOutputStream (“file.txt”);<br />
Out.writeBytes (“<end>/n”);<br />
B. OutputStream os= new FileOutputStream (“file.txt”, true);<br />
DataOutputStream out = new DataOutputStream(os);<br />
out.writeBytes (“<end>/n”);<br />
C. OutputStream os= new FileOutputStream (“file.txt”);<br />
DataOutputStream out = new DataOutputStream(os);<br />
out.writeBytes (“<end>/n”);<br />
D. OutputStream os= new OutputStream (“file.txt”, true);<br />
DataOutputStream out = new DataOutputStream(os);<br />
out.writeBytes (“<end>/n”);<br />
Answer: B<br />
Question No 41<br />
Given:<br />
1. public class X (<br />
2. public object m () {<br />
3. object o = new float (3.14F);<br />
4. object [] oa = new object [1];<br />
5. oa[0]= o;<br />
6. o = null;<br />
7. return oa[0];<br />
8. }<br />
9. }<br />
When is the float object created in line 3, eligible for garbage collection?<br />
A. Just after line 5<br />
B. Just after line 6<br />
C. Just after line 7 (that is, as the method returns)<br />
D. Never in this method.<br />
Answer: D<br />
<br />
Question No 42<br />
Given:<br />
3. string foo = “ABCDE”;<br />
4. foo.substring(3);<br />
5. foo.concat(“XYZ”);<br />
6.<br />
Type the value of foo at line 6.<br />
Answer: ABCDE<br />
Question No 43<br />
Which method is an appropriate way to determine the cosine of 42 degrees?<br />
A. Double d = Math.cos(42);<br />
B. Double d = Math.cosine(42);<br />
C. Double d = Math.cos(Math.toRadians(42));<br />
D. Double d = Math.cos(Math.toDegrees(42));<br />
E. Double d = Math.cosine(Math.toRadians(42));<br />
Answer: C<br />
Question No 44<br />
You need to store elements in a collection that guarantees that no duplicates are stored and all elements<br />
can be accessed in natural order. Which interface provides that capability?<br />
A. Java.util.Map.<br />
B. Java.util.Set.<br />
C. Java.util.List.<br />
D. Java.util.StoredSet.<br />
E. Java.util.StoredMap.<br />
F. Java.util.Collection.<br />
Answer: D<br />
Question No 45<br />
Which statement is true for the class java.util.HashSet?<br />
A. The elements in the collection are ordered.<br />
B. The collection is guaranteed to be immutable.<br />
C. The elements in the collection are guaranteed to be unique.<br />
D. The elements in the collection are accessed using a unique key.<br />
E. The elements in the collections are guaranteed to be synchronized.<br />
Answer: C<br />
Question No 46<br />
Given:<br />
1. public class IfTest (<br />
2. public static void main(string[]args) {<br />
3. int x = 3;<br />
4. int y = 1;<br />
5. if (x = y)<br />
6. system.out.printIn(“Not equal”);<br />
7. else<br />
8. system.out.printIn(“Equal”);<br />
9. }<br />
10. )<br />
What is the result?<br />
A. The output is “Equal”<br />
B. The output in “Not Equal”<br />
C. An error at line 5 causes compilation to fall.<br />
D. The program executes but does not print a message.<br />
Answer: C<br />
Question No 47<br />
Exhibit:<br />
1. public class test (<br />
2. public static void main(string args[]) {<br />
3. int 1= 0;<br />
4. while (i) {<br />
5. if (i==4) {<br />
6. break;<br />
7. )<br />
8. ++i;<br />
9. )<br />
10.<br />
11. )<br />
12. )<br />
What is the value of i at line 10?<br />
A. 0<br />
B. 3<br />
C. 4<br />
D. 5<br />
E. The code will not compile.<br />
Answer: E<br />
Question No 48<br />
Given:<br />
3. int i= 1, j= 10 ;<br />
4. do (<br />
5. if (i++> --j) continue;<br />
6. ) while (i<5);<br />
After execution, what are the values for I and j?<br />
A. i = 6 and j= 5<br />
B. i = 5 and j= 5<br />
C. i = 6 and j= 4<br />
D. i = 5 and j= 6<br />
E. i = 6 and j= 6<br />
Answer: D<br />
Question No 49<br />
Given:<br />
1. switch (i) {<br />
2. default:<br />
310-025<br />
Leading the way in IT testing and certification tools, www.testking.com<br />
- 27 -<br />
3. System.out.printIn(“Hello”);<br />
4. )<br />
What are the two acceptable types for the variable i? (Choose Two)<br />
A. Char<br />
B. Byte<br />
C. Float<br />
D. Double<br />
E. Object<br />
Answer: A, B<br />
Question No 50<br />
Given:<br />
1. public class foo {<br />
2. public static void main (string[]args)<br />
3. try {return;}<br />
4. finally {system.out.printIn(“Finally”);}<br />
5. }<br />
6. )<br />
What is the result?<br />
A. The program runs and prints nothing.<br />
B. The program runs and prints “Finally”<br />
C. The code compiles, but an exception is thrown at runtime.<br />
D. The code will not compile because the catch block is missing.<br />
Answer: B                            </td>
                            <td valign="top" width="14%"> 
                              <div align=right><font color=gray>&nbsp;&nbsp;&nbsp;&nbsp;</font></div>
                              <script type="text/javascript"><!--
google_ad_client = "pub-1552958637257019";
google_ad_width = 160;
google_ad_height = 600;
google_ad_format = "160x600_as";
google_ad_channel ="";
google_ad_type = "text";
google_color_border = "A8DDA0";
google_color_bg = "EBFFED";
google_color_link = "0000CC";
google_color_url = "008000";
google_color_text = "6F6F6F";
//--></script>
                              <script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
                            </td>
                          </tr>
                        </table>
                        <p> 
                      </td>
                      <td valign="top" width="1%">&nbsp; </td>
                    </tr>
                    <tr> 
                      <td width="99%"> 
                                              </td>
                      <td width="1%">&nbsp;</td>
                    </tr>
                  </table>

				  
				  </td>
              <tr> 
                <td valign=middle height="73">
  
                </td>
            </table></td>
        <tr> 
          <td valign=top height="73"> <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
              <tr> 
                <td width="1%" height="31">&nbsp;</td>
                <td width="99%" height="31"> 
                  <p align="left"><font color=red><img src='http://www.cn-java.com/images/smalllogo.gif'>整理发布</font></p>
                  <p align="right">&nbsp;</p>
                  <p align="left">&nbsp;</p>

                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td bgcolor="#DCDCE7"> <table width="96%" border="0" cellspacing="0" cellpadding="0" align="center">
                          <tr> 
                            <td> 
                                                          </td>
                          </tr>
                        </table></td>
                    </tr>
                  </table>
                  <form method="post" name="formMsg" action="sendPinglun.php?tg=news.php"  >
                    <p><font color="#FF0000"><b>你还没有登录</b> </font><a target='_self' href='../login.php?path_point=http://www.cn-java.com/target/news.php?news_id=3096'>登录</a> <a target='_blank' href='http://www.cn-java.com/user_step1.php'>免费申请一个帐户</a></p><input type=hidden name=news_id value=3096>                    <p align="left"> 评论内容不超过255个字符<br>
                      <textarea name="mypinglun" cols="50" rows="4"></textarea>
                      <input type="submit" class ="unnamed5" name="Submit" value="送出我的评论内容">
                    </p>
                  </form>
                  <p align="right">&nbsp;</p>
                  <p align="right"><font size="2"><img src="../images/print.gif" width="23" height="23"><a href="Javascript:js_callpage('./news_print.php?news_id=3096')">打印文章</a><img src="../images/__chazhao.gif" width="20" height="20"><a href="../search_result.php" target='_self'>文章查询</a></font></p></td>
              </tr>
              <tr> 
                <td width="1%" bordercolor="#CCCCCC">&nbsp;</td>
                <td bgcolor="#CCCCFF" width="99%">推荐文章</td>
              </tr>
              <tr> 
                <td width="1%" bordercolor="#CCCCCC">&nbsp;</td>
                <td width="99%" bgcolor="#EEF7FF"> 
                  <ol start=1>  <li> 	  <a   href='./news.php?news_id=828'><img src='http://www.cn-java.com/images/cool.gif' border=0>SUN认证Java2程序员考试(SCJP) 试题解析</a>  </li>  <li> 	  <a   href='./news.php?news_id=2215'><img src='http://www.cn-java.com/images/cool.gif' border=0>Java程序员(SCJP)和开发员(SCJD)认证</a>  </li>  <li> 	  <a   href='./news.php?news_id=1851'><img src='http://www.cn-java.com/images/cool.gif' border=0>JAVA认证问答</a>  </li>  <li> 	  <a   href='./news.php?news_id=704'><img src='http://www.cn-java.com/images/cool.gif' border=0>SCJP Mock Exam 1</a>  </li>  <li> 	  <a   href='./news.php?news_id=701'><img src='http://www.cn-java.com/images/cool.gif' border=0>SCJP Mock Exam 4</a>  </li>  <li> 	  <a   href='./news.php?news_id=823'><img src='http://www.cn-java.com/images/cool.gif' border=0>Java IT技术认证为什么火?</a>  </li>  <li> 	  <a   href='./news.php?news_id=2218'><img src='http://www.cn-java.com/images/cool.gif' border=0>SCJP认证套题解析之一</a>  </li>  <li> 	  <a   href='./news.php?news_id=581'><img src='http://www.cn-java.com/images/cool.gif' border=0>SCJP认证套题解析卷1</a>  </li>  <li> 	  <a   href='./news.php?news_id=703'><img src='http://www.cn-java.com/images/cool.gif' border=0>SCJP Mock Exam 2</a>  </li>  <li> 	  <a   href='./news.php?news_id=702'><img src='http://www.cn-java.com/images/cool.gif' border=0>SCJP Mock Exam 3</a>  </li></ol>                </td>
              </tr>
              <tr> 
                <td width="1%" bordercolor="#CCCCCC">&nbsp;</td>
                <td width="99%" bgcolor="#CCCCFF">&nbsp;</td>
              </tr>
            </table></td>
        <tr>
          <td valign=top height="73">&nbsp;</td>
      </table>
    </td>
  </tr>
</table>
<p>&nbsp;</p></body>
</html>

⌨️ 快捷键说明

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