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: 71 – (Topic 1)
Given:
-
public class TestSeven extends Thread {
-
private static int x;
-
public synchronized void doThings() {
-
int current = x;
-
current ;
-
x = current; 7. }
-
public void run() {
-
doThings();
10. } 11.}
Which statement is true?
-
Compilation fails.
-
Declaring the doThings() method as static would make the class thread-safe.
-
Synchronizing the run() method would make the class thread-safe.
-
Wrapping the statements within doThings() in a synchronized(new Object()) { } block would make the class thread-safe.
-
An exception is thrown at runtime.
-
The data in variable quot;xquot; are protected from concurrent access problems.
Answer: B
Question No: 72 DRAG DROP – (Topic 1)
Click the Task button.
Answer:
Question No: 73 – (Topic 1)
Given:
-
public class TestFive {
-
private int x;
-
public void foo() {
-
int current = x;
-
x = current 1; 6. }
-
-
7. public void go() {
8. for(int i = 0; i lt; 5; i ) {
-
new Thread() {
-
public void run() {
-
foo();
-
System.out.print(x quot;, quot;);
13. } }.start(); 14. } }
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ? (Choose two.)
-
change the variable declaration on line 2 to private volatile int x;
-
wrap the code inside the foo() method with a synchronized( this ) block
-
change line 7 to public synchronized void go() {
-
wrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here }
-
move the line 12 print statement into the foo() method
Answer: B,E
Question No: 74 – (Topic 1)
Given:
-
public static void main(String[] args) {
-
String str = quot;nullquot;;
-
if (str == null) {
-
System.out.println(quot;nullquot;);
-
} else (str.length() == 0) {
-
System.out.println(quot;zeroquot;);
-
} else {
-
System.out.println(quot;somequot;);
19. }
20. }
What is the result?
-
An exception is thrown at runtime.
-
null
-
Compilation fails.
-
zero
-
some
Answer: C
Question No: 75 – (Topic 1)
Given:
-
public void genNumbers() {
-
ArrayList numbers = new ArrayList(); 13. for (int i=0; ilt;10; i ) {
-
int value = i * ((int) Math.random());
-
Integer intObj = new Integer(value);
-
numbers.add(intObj);
17. }
18. System.out.println(numbers);
19. }
Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?
-
Line 19
-
Line 16
-
Line 17
-
The object is NOT a candidate for garbage collection.
-
Line 18
Answer: A
Question No: 76 – (Topic 1)
Given:
-
// some code here
-
try {
-
// some code here
-
} catch (SomeException se) {
-
// some code here
-
} finally {
-
// some code here
38. }
Under which three circumstances will the code on line 37 be executed? (Choose three.)
-
The code on line 31 throws an exception.
-
The code on line 35 throws an exception.
-
The code on line 33 executes successfully.
-
The code on line 33 throws an exception.
-
The instance gets garbage collected.
Answer: B,C,D
Question No: 77 – (Topic 1)
Given:
-
class Cup { }
-
class PoisonCup extends Cup { }
…
-
public void takeCup(Cup c) {
-
if (c instanceof PoisonCup) {
-
System.out.println(quot;Inconceivable!quot;);
-
} else if (c instanceof Cup) {
-
System.out.println(quot;Dizzying intellect!quot;);
-
} else {
-
System.exit(0);
28. }
29. }
And the execution of the statements:
Cup cup = new PoisonCup(); takeCup(cup);
What is the output?
-
An exception is thrown at runtime.
-
Compilation fails because of an error in line 22.
-
Dizzying intellect!
-
Inconceivable!
-
The code runs with no output.
Answer: D
Question No: 78 – (Topic 1)
Given:
-
public class Bar {
-
static void foo( int… x ) {
-
// insert code here
13. }
14. }
Which two code fragments, inserted independently at line 12, will allow the class to
compile? (Choose two.)
-
for( int i=0; ilt; x.length; i ) System.out.println(x[i]);
-
for( int z : x ) System.out.println(z);
-
foreach( x ) System.out.println(z);
-
while( x.hasNext() ) System.out.println( x.next() );
Answer: A,B
Question No: 79 DRAG DROP – (Topic 1)
Click the Task button.
Answer:
Question No: 80 – (Topic 1)
Given:
-
public static Collection get() {
-
Collection sorted = new LinkedList();
-
sorted.add(quot;Bquot;); sorted.add(quot;Cquot;); sorted.add(quot;Aquot;);
-
return sorted;
15. }
-
public static void main(String[] args) {
-
for (Object obj: get()) {
-
System.out.print(obj quot;, quot;);
19. }
20. }
What is the result?
-
Compilation fails.
-
B, C, A,
-
The code runs with no output.
-
A, B, C,
-
An exception is thrown at runtime.
Answer: B
100% Ensurepass Free Download!
–Download Free Demo:1z0-853 Demo PDF
100% Ensurepass Free Guaranteed!
–1z0-853 Dumps
EnsurePass | ExamCollection | Testking | |
---|---|---|---|
Lowest Price Guarantee | Yes | No | No |
Up-to-Dated | Yes | No | No |
Real Questions | Yes | No | No |
Explanation | Yes | No | No |
PDF VCE | Yes | No | No |
Free VCE Simulator | Yes | No | No |
Instant Download | Yes | No | No |
100-105 Dumps VCE PDF
200-105 Dumps VCE PDF
300-101 Dumps VCE PDF
300-115 Dumps VCE PDF
300-135 Dumps VCE PDF
300-320 Dumps VCE PDF
400-101 Dumps VCE PDF
640-911 Dumps VCE PDF
640-916 Dumps VCE PDF
70-410 Dumps VCE PDF
70-411 Dumps VCE PDF
70-412 Dumps VCE PDF
70-413 Dumps VCE PDF
70-414 Dumps VCE PDF
70-417 Dumps VCE PDF
70-461 Dumps VCE PDF
70-462 Dumps VCE PDF
70-463 Dumps VCE PDF
70-464 Dumps VCE PDF
70-465 Dumps VCE PDF
70-480 Dumps VCE PDF
70-483 Dumps VCE PDF
70-486 Dumps VCE PDF
70-487 Dumps VCE PDF
220-901 Dumps VCE PDF
220-902 Dumps VCE PDF
N10-006 Dumps VCE PDF
SY0-401 Dumps VCE PDF