Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-851
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-851.html
Java Standard Edition 6 Programmer Certified Professional Exam
Question No: 141 – (Topic 2)
Given:
-
public class Breaker2 {
-
static String o = quot;quot;;
-
public static void main(String[] args) {
-
z:
5. for(int x = 2; x lt; 7; x ) {
-
if(x==3) continue;
-
if(x==5) break z;
-
o = o x; 9. }
-
System.out.println(o);
11. }
12. }
What is the result?
-
2
-
24 C. 234 D. 246 E. 2346
F. Compilation fails.
Answer: B
Question No: 142 – (Topic 2)
Given:
-
-
public void testIfA() {
-
if (testIfB(quot;Truequot;)) {
-
System.out.println(quot;Truequot;);
-
} else {
-
System.out.println(quot;Not truequot;);
16. }
17. }
-
public Boolean testIfB(String str) {
-
return Boolean.valueOf(str);
20. }
What is the result when method testIfA is invoked?
-
True
-
Not true
-
An exception is thrown at runtime.
-
Compilation fails because of an error at line 12.
-
Compilation fails because of an error at line 19.
Answer: A
Question No: 143 – (Topic 2)
Given:
-
public class Donkey {
-
public static void main(String[] args) {
-
boolean assertsOn = false;
-
assert (assertsOn) : assertsOn = true;
-
if(assertsOn) {
-
System.out.println(quot;assert is onquot;); 7. }
8. }
9. }
If class Donkey is invoked twice, the first time without assertions enabled, and the second time with assertions enabled, what are the results?
-
no output
-
no output assert is on
-
assert is on
-
no output
An AssertionError is thrown.
-
assert is on
-
-
An AssertionError is thrown.
Answer: D
Question No: 144 – (Topic 2)
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 instance gets garbage collected.
-
The code on line 33 throws an exception.
-
The code on line 35 throws an exception.
-
The code on line 31 throws an exception.
-
The code on line 33 executes successfully.
Answer: B,C,E
Question No: 145 – (Topic 2)
Given:
-
public void go() {
-
String o = quot;quot;;
-
z:
25. for(int x = 0; x lt; 3; x ) { 26. for(int y = 0; y lt; 2; y ) {
27. if(x==1) break;
28. if(x==2 amp;amp; y==1) break z;
29. o = o x y;
30. }
31. }
32. System.out.println(o);
33. }
What is the result when the go() method is invoked?
A. 00
B. 0001
C. 000120
D. 00012021
-
Compilation fails.
-
An exception is thrown at runtime.
Answer: C
Question No: 146 – (Topic 2)
Given:
-
static void test() {
-
try {
-
String x = null;
-
System.out.print(x.toString() quot; quot;);
15. }
16. finally { System.out.print(quot;finally quot;); }
17. }
-
public static void main(String[] args) {
-
try { test(); }
-
catch (Exception ex) { System.out.print(quot;exception quot;); }
21. }
What is the result?
-
null
-
finally
-
null finally
-
Compilation fails.
-
finally exception
Answer: E
Question No: 147 – (Topic 2)
Given:
-
interface Foo {}
-
class Alpha implements Foo {}
-
class Beta extends Alpha {}
-
class Delta extends Beta {
-
public static void main( String[] args ) {
-
Beta x = new Beta();
-
// insert code here
17. }
18. }
Which code, inserted at line 16, will cause a java.lang.ClassCastException?
-
Alpha a = x;
-
Foo f = (Delta)x;
-
Foo f = (Alpha)x;
-
Beta b = (Beta)(Alpha)x;
Answer: B
Question No: 148 – (Topic 2)
Given:
-
try {
-
// some code here
-
} catch (NullPointerException e1) {
-
System.out.print(quot;aquot;);
-
} catch (Exception e2) {
-
System.out.print(quot;bquot;);
-
} finally {
-
System.out.print(quot;cquot;);
41. }
If some sort of exception is thrown at line 34, which output is possible?
-
a
-
b
-
c
-
ac
-
abc
Answer: D
Question No: 149 – (Topic 2)
Given:
-
public class Test {
-
public enum Dogs {collie, harrier, shepherd};
-
public static void main(String [] args) {
-
Dogs myDog = Dogs.shepherd;
-
switch (myDog) {
-
case collie:
-
System.out.print(quot;collie quot;);
-
case default:
-
System.out.print(quot;retriever quot;);
-
case harrier:
-
System.out.print(quot;harrier quot;);
22. }
23. }
24. }
What is the result?
-
harrier
-
shepherd
-
retriever
-
Compilation fails.
-
retriever harrier
-
An exception is thrown at runtime.
Answer: D
Question No: 150 – (Topic 2)
Click the Exhibit button. Given: ClassA a = new ClassA(); a.methodA(); What is the result?
-
Compilation fails.
-
ClassC is displayed.
-
The code runs with no output.
-
An exception is thrown at runtime.
Answer: D
100% Ensurepass Free Download!
–Download Free Demo:1z0-851 Demo PDF
100% Ensurepass Free Guaranteed!
–1z0-851 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