)51-91/147的文章 name=description>


SCJP考试题310-025(第二套<3>)51-91/147
来源:优易学  2011-9-22 19:53:22   【优易学:中国教育考试门户网】   资料下载   IT书店

QUESTION NO: 78
Which two statements are true regarding the creation of a default constructor? (Choose Two)
A. The default constructor initializes method variables.
B. The compiler always creates a default constructor for every class.
C. The default constructor invokes the no-parameter constructor of the superclass.
D. The default constructor initializes the instance variables declared in the class.
E. When a class has only constructors with parameters, the compiler does not create a default
constructor.
Answer: D, E
QUESTION NO: 79
Exhibit:
1. class super {
2. public int getLength() {return 4;}
3. }
4.
5. public class Sub extends Super {
6. public long getLength() {return 5;}
7.
8. public static void main (String[]args) {
9. super sooper = new Super ();
10. Sub sub = new Sub();
11. System.out.printIn(
12. sooper.getLength()+ “,” + sub.getLength() };
13. }
14. }
What is the output?
A. 4, 4
B. 4, 5
C. 5, 4
D. 5, 5
E. The code will not compile.
Answer: E
QUESTION NO: 80
Given:
1. public abstract class Test {
2. public abstract void methodA();
3.
4. public abstract void methodB()
5. {
6. System.out.printIn(“Hello”);
7. }
8. }
Which three changes (made independently) allow the code to compile? (Choose Three)
A. Add a method body to methodA.
B. Replace lines 5-7 with a semicolon (“.”)
C. Remove the abstract qualifier from the declaration of Test.
D. Remove the abstract qualifier from the declaration of methodB.
E. Remove the abstract qualifier from the declaration of methodA.
F. Remove methodB in its entirely and change class o interface in line 1.
Answer: B, D, F

QUESTION NO: 81
Which determines if “prefs” is a directory and exists on the file system?
A. Boolean exists=Directory.exists (“prefs”);
B. Boolean exists=(new File(“prefs”)).isDir();
C. Boolean exists=(new Directory(“prefs”)).exists();
D. Boolean exists=(new File(“prefs”)).isDirectory();
E. Boolean exists=true;
Try{
Directory d = new Directory(“prefs”);
}
catch (FileNotFoundException e) {
exists = false;
}
Answer: D
QUESTION NO: 82
Which two create an InputStream and open file the “file.txt” for reading? (Choose Two)
A. InputStream in=new FileReader(“file.txt”);
B. InputStream in=new FileInputStream(“file.txt”);
C. InputStream in=new InputStreamFileReader (“file.txt”, “read”);
D. FileInputStream in=new FileReader(new File(“file.txt”));
E. FileInputStream in=new FileInputStream(new File(“file.txt”));
Answer: B, E
QUESTION NO 83
Which two construct an OutputSream that appends to the file “file.txt”? (Choose Two)
A. OutputStream out=new FileOutputStream(“file.txt”);
B. OutputStream out=new FileOutputStream(“file.txt”, “append”);
C. FileOutputStream out=new FileOutputStream(“file.txt”, true);
D. FileOutputStream out=new FileOutputStream(new file(“file.txt”));
E. OutputStream out=new FileOutputStream(new File(“file.txt”)true);
Answer: C, E

QUESTION NO: 84
Which constructs a BufferedIputStream?
A. New BufferedInputStream(“in.txt”);
B. New BufferedInputStream(new File(“in.txt”));
C. New BufferedInputStream(new Writer(“in.txt”));
D. New BufferedInputStream(new Writer(“in.txt”));
E. New BufferedInputStream(new InputStream(“in.txt”));
F. New BufferedInputStream(new FileInputStream(“in.txt”));
Answer: F
QUESTION NO: 85
Which is a valid identifier?
A. false
B. default
C. _object
D. a-class
Answer: C
QUESTION NO: 86
Exhibit:
1. package foo;
2.
3. import java.util.Vector;
4.
5. private class MyVector extends Vector {
6. int i = 1;
7. public MyVector() {
8. i = 2;
9. }
10. }
11.
12. public class MyNewVector extends MyVector {
13. public MyNewVector () {
14. i = 4;
15. }
16. public static void main (String args []) {
17. MyVector v = new MyNewVector();
18. }
19. }
The file MyNewVector.java is shown in the exhibit.
What is the result?
A. Compilation will succeed.
B. Compilation will fail at line 5.
C. Compilation will fail at line 6.
D. Compilation will fail at line 14.
E. Compilation will fail at line 17.
Answer: B

上一页  [1] [2] [3] [4] [5] [6] 下一页

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训