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

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

📁 这是多次JAVA考试试题或模拟试题集锦
💻 HTM
📖 第 1 页 / 共 3 页
字号:
E. Int ia [][] = (4, 5, 6) (1, 2, 3)<br />
Answer: A, D<br />
QUESTION NO 130<br />
Given:<br />
1. public class ExceptionTest {<br />
2. class TestException extends Exception {}<br />
3. public void runTest () throws TestException {}<br />
4. public void test () /* Point X*/ {<br />
5. runTest ();<br />
6. }<br />
7. }<br />
At point X on line 4, which code can be added to make the code compile?<br />
A. Throws Exception.<br />
B. Catch (Exception e).<br />
C. Throws RuntimeException.<br />
D. Catch (TestException e).<br />
E. No code is necessary.<br />
Answer: B<br />
QUESTION NO 131<br />
Exhibit:<br />
1. public class SwitchTest {<br />
2. public static void main (String []args) {<br />
3. System.out.PrintIn(“value =” +switchIt(4));<br />
4. }<br />
5. public static int switchIt(int x) {<br />
6. int j = 1;<br />
7. switch (x) {<br />
8. case 1: j++;<br />
9. case 2: j++;<br />
10. case 3: j++;<br />
11. case 4: j++;<br />
12. case 5: j++;<br />
13. default:j++;<br />
14. }<br />
15. return j + x;<br />
16. }<br />
17. }<br />
What is the output from line 3?<br />
A. Value = 3<br />
B. Value = 4<br />
C. Value = 5<br />
D. Value = 6<br />
E. Value = 7<br />
F. Value = 8<br />
Answer: F<br />
QUESTION NO 132<br />
Which four types of objects can be thrown using the throw statement? (Choose Four)<br />
A. Error<br />
B. Event<br />
C. Object<br />
D. Exception<br />
E. Throwable<br />
F. RuntimeException<br />
Answer: A, D, E, F<br />
QUESTION NO 133<br />
Given:<br />
1. public class ForBar {<br />
2. public static void main(String []args) {<br />
3. int i = 0, j = 5;<br />
4. tp: for (;;) {<br />
5. i ++;<br />
6. for(;;)<br />
7. if(i > --j) break tp;<br />
8. }<br />
9. system.out.printIn(“i = ” + i + “, j = “+ j);<br />
10. }<br />
11. }<br />
What is the result?<br />
A. The program runs and prints “i=1, j=0”<br />
B. The program runs and prints “i=1, j=4”<br />
C. The program runs and prints “i=3, j=4”<br />
D. The program runs and prints “i=3, j=0”<br />
E. An error at line 4 causes compilation to fail.<br />
F. An error at line 7 causes compilation to fail.<br />
Answer: A<br />
QUESTION NO 134<br />
Which two can directly cause a thread to stop executing? (Choose Two)<br />
A. Exiting from a synchronized block.<br />
B. Calling the wait method on an object.<br />
C. Calling the notify method on an object.<br />
D. Calling the notifyAll method on an object.<br />
E. Calling the setPriority method on a thread object.<br />
Answer: B, E<br />
QUESTION NO 135<br />
Given:<br />
1. public class Foo implements Runnable (<br />
2. public void run (Thread t) {<br />
3. system.out.printIn(“Running.”);<br />
4. }<br />
5. public static void main (String[] args) {<br />
6. new thread (new Foo()).start();<br />
7. )<br />
8. )<br />
What is the result?<br />
A. An exception is thrown.<br />
B. The program exists without printing anything.<br />
C. An error at line 1 causes compilation to fail.<br />
D. An error at line 6 causes the compilation to fail.<br />
E. “Running” is printed and the program exits.<br />
Answer: C<br />
QUESTION NO 136<br />
Which constructs a DataOutputStream?<br />
A. New dataInputStream(“in.txt”);<br />
B. New dataInputStream(new file(“in.txt”));<br />
C. New dataInputStream(new writer(“in.txt”));<br />
D. New dataInputStream(new FileWriter(“in.txt”));<br />
E. New dataInputStream(new InputStream(“in.txt”));<br />
F. New dataInputStream(new FileInputStream(“in.txt”));<br />
Answer: F<br />
QUESTION NO 137<br />
Which can be used to decode charS for output?<br />
A. Java.io.InputStream.<br />
B. Java.io.EncodedReader.<br />
C. Java.io.InputStreamReader.<br />
D. Java.io.InputStreamWriter.<br />
E. Java.io.BufferedInputStream.<br />
Answer: C<br />
QUESTION NO 138<br />
Given:<br />
1. public class Test {<br />
2. public static void main (String [] args) {<br />
3. string foo = “blue”;<br />
4. string bar = foo;<br />
5. foo = “green”;<br />
6. System.out.printIn(bar);<br />
7. }<br />
8. }<br />
What is the result?<br />
A. An exception is thrown.<br />
B. The code will not compile.<br />
C. The program prints “null”<br />
D. The program prints “blue”<br />
E. The program prints “green”<br />
Answer: D<br />
QUESTION NO 139<br />
Which code determines the int value foo closest to a double value bar?<br />
A. Int foo = (int) Math.max(bar);<br />
B. Int foo = (int) Math.min(bar);<br />
C. Int foo = (int) Math.abs(bar);<br />
D. Int foo = (int) Math.ceil(bar);<br />
E. Int foo = (int) Math.floor(bar);<br />
F. Int foo = (int) Math.round(bar);<br />
Answer: F<br />
QUESTION NO 140<br />
Which two demonstrate encapsulation of data? (Choose Two)<br />
A. Member data have no access modifiers.<br />
B. Member data can be modified directly.<br />
C. The access modifier for methods is protected.<br />
D. The access modifier to member data is private.<br />
E. Methods provide for access and modification of data.<br />
Answer: D, E<br />
QUESTION NO 141<br />
Exhibit:<br />
1. class A {<br />
2. public String toString () {<br />
3. return “4”;<br />
4. }<br />
5. }<br />
6. class B extends A {<br />
7. 8. public String toString () {<br />
8. return super.toString() + “3”;<br />
9. }<br />
10. }<br />
11. public class Test {<br />
12. public static void main(String[]args) {<br />
13. System.out.printIn(new B());<br />
14. }<br />
15. }<br />
What is the result?<br />
A. Compilation succeeds and 4 is printed.<br />
B. Compilation succeeds and 43 is printed.<br />
C. An error on line 9 causes compilation to fail.<br />
D. An error on line 14 causes compilation to fail.<br />
E. Compilation succeeds but an exception is thrown at line 9.<br />
Answer: B<br />
QUESTION NO 142<br />
Which two statements are true? (Choose Two)<br />
A. An anonymous inner class can be declared inside of a method<br />
B. An anonymous inner class constructor can take arguments in some situation.<br />
C. An anonymous inner class that is a direct subclass that is a direct subclass of Object can implement<br />
multiple interfaces.<br />
D. Even if a class Super does not implement any interfaces, it is still possible to define an anonymous<br />
inner class that is an immediate subclass of Super that implements a single interface.<br />
E. Event if a class Super does not implement any interfaces, it is still possible to define an anonymous<br />
inner class that is an immediate subclass of Super that implements multiple interfaces.<br />
Answer: A, B<br />
QUESTION NO 143<br />
Given:<br />
1. public class MethodOver {<br />
2. private int x, y;<br />
3. private float z;<br />
4. public void setVar(int a, int b, float c){<br />
5. x = a;<br />
6. y = b;<br />
7. z = c;<br />
8. }<br />
9. }<br />
Which two overload the setVar method? (Choose Two)<br />
A. void setVar (int a, int b, float c){<br />
x = a;<br />
y = b;<br />
z = c;<br />
}<br />
B. public void setVar(int a, float c, int b) {<br />
setVar(a, b, c);<br />
}<br />
C. public void setVar(int a, float c, int b) {<br />
this(a, b, c);<br />
}<br />
D. public void setVar(int a, float b){<br />
x = a;<br />
z = b;<br />
}<br />
E. public void setVar(int ax, int by, float cz) {<br />
x = ax;<br />
y = by;<br />
z = cz;<br />
}<br />
Answer: B, D<br />
QUESTION NO 144<br />
Which statements about static inner classes are true? (Choose Two)<br />
A. A static inner class requires a static initializer.<br />
B. A static inner class requires an instance of the enclosing class.<br />
C. A static inner class has no reference to an instance of the enclosing class.<br />
D. A static inner class has access to the non-static members of the outer class.<br />
E. Static members of a static inner class can be referenced using the class name of the static inner<br />
class.<br />
Answer: C, E<br />
QUESTION NO 145<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. oa[0] = null;<br />
9. return o;<br />
9. }<br />
10. }<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.<br />
D. Just after line 8(that is, as the method returns).<br />
Answer: C<br />
QUESTION NO 146<br />
Which two interfaces provide the capability to store objects using a key-value pair? (Choose Two)<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: A, E<br />
QUESTION NO 147<br />
Which interface does java.util.Hashable implement?<br />
A. Java.util.Map.<br />
B. Java.util.List.<br />
C. Java.util.Hashable.<br />
D. Java.util.Collection.<br />
Answer: A                            </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> 
                              &nbsp;<font color=red>发言人:</font><b>logcos</b>&nbsp;&nbsp;&nbsp;日期:2005-02-21<hr>不太会做,<br />
有没有中文的啊?!<br />
<br><br><br>&nbsp;<font color=red>发言人:</font><b>过客</b>&nbsp;&nbsp;&nbsp;日期:2005-03-17<hr>拼写错误太多<br><br><br>&nbsp;<font color=red>发言人:</font><b>过客</b>&nbsp;&nbsp;&nbsp;日期:2005-03-21<hr>是不是原题呀,怎么那么多错误!<br><br><br>                            </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=3106'>登录</a> <a target='_blank' href='http://www.cn-java.com/user_step1.php'>免费申请一个帐户</a></p><input type=hidden name=news_id value=3106>                    <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=3106')">打印文章</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 + -