阿摩線上測驗
登入
首頁
>
OJCP(SCJP)
> 無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 101-150#83070
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 101-150#83070
科目:
OJCP(SCJP) |
選擇題數:
48 |
申論題數:
2
試卷資訊
所屬科目:
OJCP(SCJP)
選擇題 (48)
複選題
101
Which two correctly access the DIAMETER member of the Geodetics class? (Choose two.)
(A)
(B)
(C)
(D)
102
Which code, inserted at line 15, allows the class Sprite to compile? (A) Foo{public int bar(){return 1;}} (B) new Foo{public int bar(){return 1;}} (C) new Foo(){public int bar(){return 1;}} (D) new class Foo{public int bar(){return 1;}}
103
What is the result? (A) Mr. John Doe (B) An exception is thrown at runtime. (C) Compilation fails because of an error in line 12. (D) Compilation fails because of an error in line 15. (E) Compilation fails because of an error in line 20.
104
Which code, inserted at line 15, creates an instance of the Point class defined in Line? (A) Point p = new Point(); (B) Line.Point p = new Line.Point(); (C) The Point class cannot be instatiated at line 15. (D) Line l = new Line(); l.Point p = new l.Point();
105
What is the result? (A) Compilation of class A fails. (B) Line 28 prints the value 3 to System.out. (C) Line 28 prints the value 1 to System.out. (D) A runtime error occurs when line 25 executes. (E) Compilation fails because of an error on line 28.
106
What is required at line 5 in class SomeApp to use the process method of BitUtils? (A) process(bytes); (B) BitUtils.process(bytes); (C) util.BitUtils.process(bytes); (D) SomeApp cannot use methods in BitUtils. (E) import util.BitUtils.*; process(bytes);
107
Which three code fragments, added individually at line 29, produce the output 100? (Choose three.)
1. n = 100;
2. i.setX(100);
3. o.getY().setX(100);
4. i = new Inner(); i.setX(100);
5. o.setY(i); i = new Inner(); i.setX(100);
6. i = new Inner(); i.setX(100); o.setY(i); (A) 236 (B) 246 (C) 456 (D) 2346
108
Which statement is true about the objects referenced by snoog, snooch, and booch immediately after line 23 executes? (A) None of these objects are eligible for garbage collection. (B) Only the object referenced by booch is eligible for garbage collection. (C) Only the object referenced by snoog is eligible for garbage collection. (D) Only the object referenced by snooch is eligible for garbage collection. (E) The objects referenced by snooch and booch are eligible for garbage collection.
109
Which code fragment, inserted at the end of line 12, produces the output p is 420? (A) p.setWeight(420); (B) p.changePayload(420); (C) p = new Payload(420); (D) Payload.setWeight(420); (E) p = Payload.setWeight(420);
110
What is the result? (A) r, t, t, (B) r, e, o, (C) Compilation fails. (D) An exception is thrown at runtime.
111
What is the result? (A) Compilation fails. (B) An exception is thrown at runtime. (C) doStuff x = 6 main x = 6 (D) doStuff x = 6 main x = 7 (E) doStuff x = 7 main x = 6
(AB) doStuff x = 7 main x = 7
112
What is the result? (A) collie (B) harrier (C) Compilation fails. (D) collie harrier (E) An exception is thrown at runtime.
113
Which exception or error will be thrown when a programmer attempts to run this code? (A) java.lang.StackOverflowError (B) java.lang.IllegalStateException (C) java.lang.ExceptionInInitializerError (D) java.lang.ArrayIndexOutOfBoundsException
114
Which code, inserted at line 16, correctly retrieves a local instance of a Point object? (A) Point p = Line.getPoint(); (B) Line.Point p = Line.getPoint(); (C) Point p = (new Line()).getPoint(); (D) Line.Point p = (new Line()).getPoint();
115
What is the result? (A) 6 (B) 7 (C) 10 (D) 11 (E) Compilation fails.
(AB) An exception is thrown at runtime.
複選題
116
Which two, placed on line 13, will produce the output gobstopper? (Choose two.)
1. System.load("prop.custom");
2. System.getenv("prop.custom");
3. System.property("prop.custom);
4. System.getProperty("prop.custom");
5. System.getProperties().getProperty("prop.custom"); (A) 13 (B) 23 (C) 45 (D) 245
117
What is the result when the programmer attempts to compile the code and run it with the command java Converter 12? (A) It is true that j==i. (B) It is false that j==i. (C) An exception is thrown at runtime. (D) Compilation fails because of an error in line 13.
複選題
118
Which two statements are true? (Choose two.) (A) Foo.beta() is a valid invocation of beta(). (B) Foo.alpha() is a valid invocation of alpha(). (C) Method beta() can directly call method alpha(). (D) Method alpha() can directly call method beta().
119
What is the result? (A) null (B) zero (C) some (D) Compilation fails. (E) An exception is thrown at runtime.
120
When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection? (A) Line 5 (B) Line 6 (C) Line 7 (D) Line 8 (E) Line 9
(AB) Line 10
121
What is the result? (A) harrier (B) shepherd (C) retriever (D) Compilation fails (E) retriever harrier
(AB) An exception is thrown at runtime,
122
Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection? (A) Line 16 (B) Line 17 (C) Line 18 (D) Line 19 (E) The object is NOT a candidate for garbage collection.
123
What is the result? (A) 0.0 (B) Compilation fails. (C) A ParseException is thrown by the parse method at runtime. (D) A NumberFormatException is thrown by the parse method at runtime.
124
What is the result? (A) test end (B) Compilation fails. (C) test runtime end (D) test exception end (E) A Throwable is thrown by main at runtime.
125
If some sort of exception is thrown at line 34, which output is possible? (A) a (B) b (C) c (D) ac (E) abc
複選題
126
Under which three circumstances will the code on line 37 be executed? (Choose three.) (A) The instance gets garbage collected. (B) The code on line 33 throws an exception. (C) The code on line 35 throws an exception. (D) The code on line 31 throws an exception. (E) The code on line 33 executes successfully
127
If class Donkey2 is invoked twice, the first time without assertions enabled, and the second time with assertions enabled, what are the results? (A) no output (B) no output assert is on (C) assert is on (D) no output
An Assertion Error is thrown. (E) assert is on
An AssertionError is thrown.
128
Which statement is true if a TestException is thrown on line 3 of class B? (A) Line 33 must be called within a try block. (B) The exception thrown by method1 in class A is not required to be caught. (C) The method declared on line 31 must be declared to throw a RuntimeException. (D) On line 5 of class A, the call to method2 of class B does not need to be placed in a try/catch block.
129
What is the result? (A) Compilation fails. (B) pi is bigger than 3. (C) An exception occurs at runtime. (D) pi is bigger than 3. Have a nice day. (E) pi is not bigger than 3. Have a nice day.
130
What is the result? (A) null (B) finally (C) null finally (D) Compilation fails. (E) finally exception
131
What is the result? (A) end (B) Compilation fails. (C) exception end (D) exception test end (E) A Throwable is thrown by main.
(AB) An Exception is thrown by main.
132
Which statement is true? (A) Compilation succeeds. (B) class A does not compile. (C) The method declared on line 9 cannot be modified to throw TestException. (D) TestA compiles if line 10 is enclosed in try/catch block that catches TestException.
133
What is the result? (A) Compilation fails. (B) ClassC is displayed. (C) The code runs with no output. (D) An exception is thrown at runtime.
134
What is the result? (A) B (B) B, followed by an Exception. (C) Compilation fails due to an error on line 9. (D) Compilation fails due to an error on line 14. (E) An Exception is thrown with no other output.
135
Which statement is true if a ResourceException is thrown on line 86? (A) Line 92 will not execute. (B) The connection will not be retrieved in line 85. (C) The resource connection will not be closed on line 88. (D) The enclosing method will throw an exception to its caller.
136
What is the result? (A) test (B) Exception (C) Compilation fails. (D) NullPointerException
137
What is the result? (A) X, followed by an Exception. (B) No output, and an Exception is thrown. (C) Compilation fails due to an error on line 14. (D) Compilation fails due to an error on line 16. (E) Compilation fails due to an error on line 17.
(AB) X, followed by an Exception, followed by B.
138 Which two code fragments are most likely to cause a StackOverflowError? (Choose two.)
1. int[] x = {1, 2, 3, 4, 5}; for(int y=0; y<6; y++) System.out.println(x[y]);
2. static int[] x = {7, 6, 54}; static{x[1] = 8; x[4] = 3;}
3. for(int y=10; y<10; y++) doStuff(y);
4. void doOne(int x){doTwo(x);} void doTwo(int y){doThree(y);} void doThree(int z){doTwo(z);}
5. for(int x=0; x<1000000000; x++) doStuff(x);
6. void counter(int i){counter(++i);} (A) 12 (B) 46 (C) 23 (D) 156
139
What, inserted at line 12, is the appropriate way to handle a null value?
(A) assert value == null;
(B) assert value != null : "value is null";
(C)
(D)
複選題
140
Which two statements are true if a NullPointerException is thrown on line 3 of class C? (Choose two.) (A) The application will crash. (B) The code on line 29 will be executed. (C) The code on line 5 of class A will execute. (D) The code on line 5 of class B will execute. (E) The exception will be propagated back to line 27.
141
What is the result? (A) Exception (B) A, B, Exception (C) Compilation fails because of an error in line 20. (D) Compilation fails because of an error in line 14. (E) A NullPointerException is thrown at runtime.
142
What is the result? (A) restore 400 (B) restore 403 (C) restore 453 (D) Compilation fails. (E) An exception is thrown at runtime.
144 Which capability exists only in java.io.BufferedWriter? (A) Closing an open stream. (B) Flushing an open stream. (C) Writing to an open stream. (D) Writing a line separator to an open stream.
145
Which statement is true? (A) Compilation fails. (B) The file system has a new empty directory named dir. (C) The file system has a new empty directory named newDir. (D) The file system has a directory named dir, containing a file f1.txt. (E) The file system has a directory named newDir, containing a file f1.txt.
146
Which code, inserted at line 14, will allow this class to correctly serialize and deserialize? (A) s.defaultReadObject(); (B) this = s.defaultReadObject(); (C) y = s.readInt(); x = s.readInt(); (D) x = s.readInt(); y = s.readInt();
複選題
147
Which code fragment, inserted at line 4, produces the output | 12.345|? (A) System.out.printf("|%7d| \n", d); (B) System.out.printf("|%7f| \n", d); (C) System.out.printf("|%3.7d| \n", d); (D) System.out.printf("|%3.7f| \n", d); (E) System.out.printf("|%7.3d| \n", d); (AB) System.out.printf("|%7.3f| \n", d);
148
What is the result? (A) Compilation fails. (B) An exception is thrown at runtime. (C) An instance of Forest is serialized. (D) An instance of Forest and an instance of Tree are both serialized.
150
If the user types the password aiko when prompted, what is the result? (A) password: got (B) password: got aiko (C) password: aiko got aiko (D) An exception is thrown at runtime. (E) Compilation fails due to an error on line 8.
申論題 (2)
143 Given:
System.out.printf("Pi is approximately %f and E is approximately %b", Math.PI, Math.E);
Place the values where they would appear in the output.
149 Place the Fragments into the program, so that the program will get lines from a text file. display them, and then close all the resources.
相關試卷
104年 - SCJP 201-244#99410
104年 · #99410
104年 - SCJP 51-100#99391
104年 · #99391
104年 - SCJP 151-200#99330
104年 · #99330
104年 - SCJP 1-50#41416
104年 · #41416
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 201-244#83084
#83084
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 151-200#83081
#83081
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 51-100#83056
#83056