📄 中文java技术网scjp考试题310-025(第二套1)18-147.htm
字号:
Exhibit:<br />
1. public class test {<br />
2. public static void add3 (Integer i) }<br />
3. int val = i.intValue ( );<br />
4. val += 3;<br />
5. i = new Integer (val);<br />
6. }<br />
7.<br />
8. public static void main (String args [ ] ) {<br />
9. Integer i = new Integer (0);<br />
10. add3 (i);<br />
11. system.out.printIn (i.intValue ( ) );<br />
12. }<br />
13. )<br />
What is the result?<br />
A. Compilation will fail.<br />
B. The program prints “0”.<br />
C. The program prints “3”.<br />
D. Compilation will succeed but an exception will be thrown at line 3.<br />
Answer: B<br />
Question No: 8<br />
Given:<br />
1. public class ConstOver {<br />
2. public ConstOver (int x, int y, int z) {<br />
3. }<br />
4. }<br />
Which two overload the ConstOver constructor? (Choose Two)<br />
A. ConstOver ( ) { }<br />
B. Protected int ConstOver ( ) { }<br />
C. Private ConstOver (int z, int y, byte x) { }<br />
D. Public Object ConstOver (int x, int y, int z) { }<br />
E. Public void ConstOver (byte x, byte y, byte z) { }<br />
Answer: A, C<br />
Question No: 9<br />
Given:<br />
1. public class MethodOver {<br />
2. public void setVar (int a, int b, float c) {<br />
3. }<br />
4. }<br />
Which two overload the setVar method? (Choose Two)<br />
A. Private void setVar (int a, float c, int b) { }<br />
B. Protected void setVar (int a, int b, float c) { }<br />
C. Public int setVar (int a, float c, int b) (return a;)<br />
D. Public int setVar (int a, int b, float c) (return a;)<br />
E. Protected float setVar (int a, int b, float c) (return c;)<br />
Answer: A, C<br />
Question No: 10<br />
Given:<br />
1. class BaseClass {<br />
2. Private float x = 1.0f ;<br />
3. protected float getVar ( ) ( return x;)<br />
4. }<br />
5. class Subclass extends BaseClass (<br />
6. private float x = 2.0f;<br />
7. //insert code here<br />
8. )<br />
Which two are valid examples of method overriding? (Choose Two)<br />
A. Float getVar ( ) { return x;}<br />
B. Public float getVar ( ) { return x;}<br />
C. Float double getVar ( ) { return x;}<br />
D. Public float getVar ( ) { return x;}<br />
E. Public float getVar (float f ) { return f;}<br />
Answer: B, D<br />
Question No: 11<br />
Which two demonstrate an “is a” relationship? (Choose Two)<br />
A. public interface Person { }<br />
public class Employee extends Person { }<br />
B. public interface Shape { }<br />
public class Employee extends Shape { }<br />
C. public interface Color { }<br />
public class Employee extends Color { }<br />
D. public class Species { }<br />
public class Animal (private Species species;)<br />
E. interface Component { }<br />
Class Container implements Component (<br />
Private Component[ ] children;<br />
)<br />
Answer: D, E<br />
Question No: 12<br />
Which statement is true?<br />
A. An anonymous inner class may be declared as final.<br />
B. An anonymous inner class can be declared as private.<br />
C. An anonymous inner class can implement multiple interfaces.<br />
D. An anonymous inner class can access final variables in any enclosing scope.<br />
E. Construction of an instance of a static inner class requires an instance of the enclosing outer class.<br />
Answer: D<br />
Question No 13<br />
Given:<br />
1. package foo;<br />
2.<br />
3. public class Outer (<br />
4. public static class Inner (<br />
5. )<br />
6. )<br />
Which statement is true?<br />
A. An instance of the Inner class can be constructed with “new Outer.Inner ()”<br />
B. An instance of the inner class cannot be constructed outside of package foo.<br />
C. An instance of the inner class can only be constructed from within the outer class.<br />
D. From within the package bar, an instance of the inner class can be constructed with “new inner()”<br />
Answer: A<br />
Question No 14<br />
Exhibit:<br />
1. public class enclosingone (<br />
2. public class insideone{}<br />
3. )<br />
4. public class inertest(<br />
5. public static void main (string[]args)(<br />
6. enclosingone eo= new enclosingone ();<br />
7. //insert code here<br />
8. )<br />
9. )<br />
Which statement at line 7 constructs an instance of the inner class?<br />
A. InsideOnew ei= eo.new InsideOn();<br />
B. Eo.InsideOne ei = eo.new InsideOne();<br />
C. InsideOne ei = EnclosingOne.new InsideOne();<br />
D. EnclosingOne.InsideOne ei = eo.new InsideOne();<br />
Answer: D<br />
Question No 15<br />
Exhibit:<br />
1. interface foo {<br />
2. int k = 0;<br />
3. ]<br />
4.<br />
5. public class test implements Foo (<br />
6. public static void main(String args[]) (<br />
7. int i;<br />
8. Test test = new test ();<br />
9. i= test.k;<br />
10.i= Test.k;<br />
11.i= Foo.k;<br />
12.)<br />
13.)<br />
14.<br />
What is the result?<br />
A. Compilation succeeds.<br />
B. An error at line 2 causes compilation to fail.<br />
C. An error at line 9 causes compilation to fail.<br />
D. An error at line 10 causes compilation to fail.<br />
E. An error at line 11 causes compilation to fail.<br />
Answer: A<br />
Question No 16<br />
Given:<br />
1. //point X<br />
2. public class foo (<br />
3. public static void main (String[]args) throws Exception {<br />
4. printWriter out = new PrintWriter (new<br />
5. java.io.outputStreamWriter (System.out), true;<br />
6. out.printIn(“Hello”);<br />
7. }<br />
8. )<br />
Which statement at PointX on line 1 allows this code to compile and run?<br />
A. Import java.io.PrintWriter;<br />
B. Include java.io.PrintWriter;<br />
C. Import java.io.OutputStreamWriter;<br />
D. Include java.io.OutputStreamWriter;<br />
E. No statement is needed.<br />
Answer: A<br />
Question No 17<br />
Which two statements are reserved words in Java? (Choose Two)<br />
A. Run<br />
B. Import<br />
C. Default<br />
D. Implement<br />
Answer: B, C<br />
Question No 18<br />
Which three are valid declarations of a float? (Choose Three)<br />
A. Float foo = -1;<br />
B. Float foo = 1.0;<br />
C. Float foo = 42e1;<br />
D. Float foo = 2.02f;<br />
E. Float foo = 3.03d;<br />
F. Float foo = 0x0123;<br />
Answer: A, D, F </td>
<td valign="top" width="14%">
<div align=right><font color=gray> </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%"> </td>
</tr>
<tr>
<td width="99%">
</td>
<td width="1%"> </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"> </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"> </p>
<p align="left"> </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>
<font color=red>发言人:</font><b>过客</b> 日期:2005-01-11<hr>老兄,给点专业精神行不行,你的错误太多了,第二题答案就错了,如果类型不同,即使值相同,equals()也是false,拜托你自己先弄弄清楚,千万别误人子弟哟。<br><br><br> <font color=red>发言人:</font><b>过客</b> 日期:2005-01-11<hr>靠,第六题又错,答案应该是javajavaC<br><br><br> <font color=red>发言人:</font><b>过客</b> 日期:2005-03-20<hr>老兄 想编辑你的程序好难哦 <br />
可不可以用心一点啊 <br><br><br> <font color=red>发言人:</font><b>过客</b> 日期:2005-04-05<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=3095'>登录</a> <a target='_blank' href='http://www.cn-java.com/user_step1.php'>免费申请一个帐户</a></p><input type=hidden name=news_id value=3095> <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"> </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=3095')">打印文章</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"> </td>
<td bgcolor="#CCCCFF" width="99%">推荐文章</td>
</tr>
<tr>
<td width="1%" bordercolor="#CCCCCC"> </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"> </td>
<td width="99%" bgcolor="#CCCCFF"> </td>
</tr>
</table></td>
<tr>
<td valign=top height="73"> </td>
</table>
</td>
</tr>
</table>
<p> </p></body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -