📄 中文java技术网scjp考试题310-025(第二套3)51-91-147.htm
字号:
A. Compilation will fail.<br />
B. Compilation succeeds and no exceptions are thrown.<br />
C. Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.<br />
D. Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.<br />
Answer: B<br />
QUESTION NO: 77<br />
Given:<br />
1. public class ArrayTest {<br />
2. public static void main (String[]args) {<br />
3. float f1[], f2[];<br />
4. f1 = new float [10];<br />
5. f2 = f1;<br />
6. System.out.printIn (“f2[0]=” + f2[0]);<br />
7. }<br />
8. }<br />
What is the result?<br />
A. It prints f2[0] = 0.0<br />
B. It prints f2[0] = NaN<br />
C. An error at line 5 causes compile to fail.<br />
D. An error at line 6 causes compile to fail.<br />
E. An error at line 6 causes an exception at runtime.<br />
Answer: A<br />
QUESTION NO: 78<br />
Which two statements are true regarding the creation of a default constructor? (Choose Two)<br />
A. The default constructor initializes method variables.<br />
B. The compiler always creates a default constructor for every class.<br />
C. The default constructor invokes the no-parameter constructor of the superclass.<br />
D. The default constructor initializes the instance variables declared in the class.<br />
E. When a class has only constructors with parameters, the compiler does not create a default<br />
constructor.<br />
Answer: D, E<br />
QUESTION NO: 79<br />
Exhibit:<br />
1. class super {<br />
2. public int getLength() {return 4;}<br />
3. }<br />
4.<br />
5. public class Sub extends Super {<br />
6. public long getLength() {return 5;}<br />
7.<br />
8. public static void main (String[]args) {<br />
9. super sooper = new Super ();<br />
10. Sub sub = new Sub();<br />
11. System.out.printIn(<br />
12. sooper.getLength()+ “,” + sub.getLength() };<br />
13. }<br />
14. }<br />
What is the output?<br />
A. 4, 4<br />
B. 4, 5<br />
C. 5, 4<br />
D. 5, 5<br />
E. The code will not compile.<br />
Answer: E<br />
QUESTION NO: 80<br />
Given:<br />
1. public abstract class Test {<br />
2. public abstract void methodA();<br />
3.<br />
4. public abstract void methodB()<br />
5. {<br />
6. System.out.printIn(“Hello”);<br />
7. }<br />
8. }<br />
Which three changes (made independently) allow the code to compile? (Choose Three)<br />
A. Add a method body to methodA.<br />
B. Replace lines 5-7 with a semicolon (“.”)<br />
C. Remove the abstract qualifier from the declaration of Test.<br />
D. Remove the abstract qualifier from the declaration of methodB.<br />
E. Remove the abstract qualifier from the declaration of methodA.<br />
F. Remove methodB in its entirely and change class o interface in line 1.<br />
Answer: B, D, F<br />
<br />
QUESTION NO: 81<br />
Which determines if “prefs” is a directory and exists on the file system?<br />
A. Boolean exists=Directory.exists (“prefs”);<br />
B. Boolean exists=(new File(“prefs”)).isDir();<br />
C. Boolean exists=(new Directory(“prefs”)).exists();<br />
D. Boolean exists=(new File(“prefs”)).isDirectory();<br />
E. Boolean exists=true;<br />
Try{<br />
Directory d = new Directory(“prefs”);<br />
}<br />
catch (FileNotFoundException e) {<br />
exists = false;<br />
}<br />
Answer: D<br />
QUESTION NO: 82<br />
Which two create an InputStream and open file the “file.txt” for reading? (Choose Two)<br />
A. InputStream in=new FileReader(“file.txt”);<br />
B. InputStream in=new FileInputStream(“file.txt”);<br />
C. InputStream in=new InputStreamFileReader (“file.txt”, “read”);<br />
D. FileInputStream in=new FileReader(new File(“file.txt”));<br />
E. FileInputStream in=new FileInputStream(new File(“file.txt”));<br />
Answer: B, E<br />
QUESTION NO 83<br />
Which two construct an OutputSream that appends to the file “file.txt”? (Choose Two)<br />
A. OutputStream out=new FileOutputStream(“file.txt”);<br />
B. OutputStream out=new FileOutputStream(“file.txt”, “append”);<br />
C. FileOutputStream out=new FileOutputStream(“file.txt”, true);<br />
D. FileOutputStream out=new FileOutputStream(new file(“file.txt”));<br />
E. OutputStream out=new FileOutputStream(new File(“file.txt”)true);<br />
Answer: C, E<br />
<br />
QUESTION NO: 84<br />
Which constructs a BufferedIputStream?<br />
A. New BufferedInputStream(“in.txt”);<br />
B. New BufferedInputStream(new File(“in.txt”));<br />
C. New BufferedInputStream(new Writer(“in.txt”));<br />
D. New BufferedInputStream(new Writer(“in.txt”));<br />
E. New BufferedInputStream(new InputStream(“in.txt”));<br />
F. New BufferedInputStream(new FileInputStream(“in.txt”));<br />
Answer: F<br />
QUESTION NO: 85<br />
Which is a valid identifier?<br />
A. false<br />
B. default<br />
C. _object<br />
D. a-class<br />
Answer: C<br />
QUESTION NO: 86<br />
Exhibit:<br />
1. package foo;<br />
2.<br />
3. import java.util.Vector;<br />
4.<br />
5. private class MyVector extends Vector {<br />
6. int i = 1;<br />
7. public MyVector() {<br />
8. i = 2;<br />
9. }<br />
10. }<br />
11.<br />
12. public class MyNewVector extends MyVector {<br />
13. public MyNewVector () {<br />
14. i = 4;<br />
15. }<br />
16. public static void main (String args []) {<br />
17. MyVector v = new MyNewVector();<br />
18. }<br />
19. }<br />
The file MyNewVector.java is shown in the exhibit.<br />
What is the result?<br />
A. Compilation will succeed.<br />
B. Compilation will fail at line 5.<br />
C. Compilation will fail at line 6.<br />
D. Compilation will fail at line 14.<br />
E. Compilation will fail at line 17.<br />
Answer: B<br />
QUESTION NO: 87<br />
Given:<br />
1. public class Test {<br />
2. public static void main (String[]args) {<br />
3. String foo = args[1];<br />
4. String bar = args[2];<br />
5. String baz = args[3];<br />
6. System.out.printIn(“baz = ” + baz);<br />
7. }<br />
8. }<br />
And the output:<br />
Baz = 2<br />
Which command line invocation will produce the output?<br />
A. Java Test 2222<br />
B. Java Test 1 2 3 4<br />
C. Java Test 4 2 4 2<br />
D. Java Test 4 3 2 1<br />
Answer: C<br />
<br />
QUESTION NO: 88<br />
Given:<br />
8. int index = 1;<br />
9. String [] test = new String[3];<br />
10. String foo = test[index];<br />
What is the result?<br />
E. Foo has the value “”<br />
B. Foo has the value null<br />
C. An exception is thrown<br />
D. The code will not compile<br />
Answer: B<br />
QUESTION NO: 89<br />
Given:<br />
1. public interface Foo{<br />
2. int k = 4;<br />
3. }<br />
Which three are equivalent to line 2? (Choose Three)<br />
A. Final int k = 4;<br />
B. Public int k = 4;<br />
C. Static int k = 4;<br />
D. Private int k = 4;<br />
E. Abstract int k = 4;<br />
F. Volatile int k = 4;<br />
G. Transient int k = 4;<br />
H. Protected int k = 4;<br />
Answer: A, B, C<br />
QUESTION NO: 90<br />
Given:<br />
310-025<br />
Leading the way in IT testing and certification tools, www.testking.com<br />
- 48 -<br />
1. public class foo {<br />
2. static String s;<br />
3. public static void main (String[]args) {<br />
4. system.out.printIn (“s=” + s);<br />
5. }<br />
6. }<br />
What is the result?<br />
A. The code compiles and “s=” is printed.<br />
B. The code compiles and “s=null” is printed.<br />
C. The code does not compile because string s is not initialized.<br />
D. The code does not compile because string s cannot be referenced.<br />
E. The code compiles, but a NullPointerException is thrown when toString is called.<br />
Answer: B<br />
QUESTION NO: 91<br />
Which two valid declarations of a char? (Choose Two)<br />
A. Char ch = “a”;<br />
B. Char ch = ‘\’ ‘;<br />
C. Char ch = ‘cafe’;<br />
D. Char ch = “cafe”;<br />
E. Char ch = ‘\ucafe’;<br />
F. Char ch = ‘\u10100’;<br />
G. Char ch = (char) true;<br />
Answer: B, E<br />
</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>huiwu917</b> 日期:2005-01-08<hr> 已经向我发出EMAIL的我已经发了!注意查收!!!<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=3097'>登录</a> <a target='_blank' href='http://www.cn-java.com/user_step1.php'>免费申请一个帐户</a></p><input type=hidden name=news_id value=3097> <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=3097')">打印文章</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 + -