Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-853
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-853.html
Java Standard Edition 5 Programmer Certified Professional Exam
Question No: 241 – (Topic 3)
Given:
-
public class TestOne {
-
public static void main (String[] args) throws Exception {
-
Thread.sleep(3000);
-
System.out.println(quot;sleepquot;); 5. }
6. }
What is the result?
-
The code executes normally and prints quot;sleepquot;.
-
The code executes normally, but nothing is printed.
-
Compilation fails.
-
An exception is thrown at runtime.
-
Answer: A
Question No: 242 – (Topic 3)
Given:
-
public static Iterator reverse(List list) {
-
Collections.reverse(list);
-
return list.iterator();
14. }
-
public static void main(String[] args) {
-
List list = new ArrayList();
-
list.add(quot;1quot;); list.add(quot;2quot;); list.add(quot;3quot;);
-
for (Object obj: reverse(list))
-
System.out.print(obj quot;, quot;);
20. }
What is the result?
A. 1, 2, 3,
B. 3, 2, 1,
-
The code runs with no output.
-
Compilation fails.
-
An exception is thrown at runtime.
Answer: D
Question No: 243 – (Topic 3)
Given:
-
String test = quot;This is a testquot;;
-
String[] tokens = test.split(quot;\squot;);
-
System.out.println(tokens.length); What is the result?
-
4
-
Compilation fails.
-
0
-
An exception is thrown at runtime.
-
1
Answer: B
Question No: 244 – (Topic 3)
Given:
-
public static void main(String[] args) {
-
Integer i = new Integer(1) new Integer(2);
-
switch(i) {
-
case 3: System.out.println(quot;threequot;); break;
-
default: System.out.println(quot;otherquot;); break;
16. }
17. }
What is the result?
-
three
-
Compilation fails because of an error on line 12.
-
Compilation fails because of an error on line 13.
-
other
-
An exception is thrown at runtime.
-
Compilation fails because of an error on line 15.
Answer: A
Question No: 245 – (Topic 3)
Given:
-
String[] elements = { quot;forquot;, quot;teaquot;, quot;tooquot; };
-
String first = (elements.length gt; 0) ? elements[0] : null; What is the result?
-
Compilation fails.
-
An exception is thrown at runtime.
-
The variable first is set to elements[0].
-
The variable first is set to null.
Answer: C
Question No: 246 – (Topic 3)
A programmer has an algorithm that requires a java.util.List that provides an efficient implementation of add(0, object), but does NOT need to support quick random access.
What supports these requirements?
-
java.util.ArrayList
-
java.util.Queue
-
java.util.LinearList
-
java.util.LinkedList
Answer: D
Question No: 247 DRAG DROP – (Topic 3)
Click the Task button.
Answer:
Question No: 248 – (Topic 3)
Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given:
-
-
import java.io.*;
-
class Food {Food() { System.out.print(quot;1quot;); } }
-
class Fruit extends Food implements Serializable {
-
Fruit() { System.out.print(quot;2quot;); } }
-
public class Banana2 extends Fruit { int size = 42;
-
public static void main(String [] args) {
-
Banana2 b = new Banana2();
-
b.serializeBanana2(b); // assume correct serialization
-
b = b.deserializeBanana2(b); // assume correct
-
System.out.println(quot; restored quot; b.size quot; quot;); }
-
// more Banana2 methods
24. }
What is the result?
-
1212 restored 42
-
121 restored 42
-
12 restored 42
-
1 restored 42
-
Compilation fails.
-
An exception is thrown at runtime.
Answer: B
Question No: 249 – (Topic 3)
Given:
-
class Nav{
-
public enum Direction { NORTH, SOUTH, EAST, WEST }
12. }
-
public class Sprite{
-
// insert code here
15. }
Which code, inserted at line 14, allows the Sprite class to compile?
-
Nav.Direction d = Nav.Direction.NORTH;
-
Nav.Direction d = NORTH;
-
Direction d = NORTH;
-
Direction d = Direction.NORTH;
Answer: A
Question No: 250 – (Topic 3)
Given:
-
public class Boxer1{
-
Integer i;
-
int x;
-
public Boxer1(int y) {
-
x = i y;
-
System.out.println(x); 7. }
-
-
public static void main(String[] args) {
-
new Boxer1(new Integer(4));
10. }
11. }
What is the result?
-
A NullPointerException occurs at runtime.
-
The value quot;4quot; is printed at the command line.
-
Compilation fails because of an error in line 5.
-
A NumberFormatException occurs at runtime.
-
Compilation fails because of an error in line 9.
-
An IllegalStateException occurs at runtime.
-
Answer: A