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: 41 – (Topic 1)
Which two code fragments are most likely to cause a StackOverflowError? (Choose two.)
A. int []x = {1,2,3,4,5};
for(int y = 0; y lt; 6; y ) System.out.println(x[y]); B. static int[] x = {7,6,5,4}; static { x[1] = 8;
x[4] = 3; }
C. for(int y = 10; y lt; 10; y ) doStuff(y);
D. void doOne(int x) { doTwo(x); } void doTwo(int y) { doThree(y); } void doThree(int z) { doTwo(z); }
E. for(int x = 0; x lt; 1000000000; x ) doStuff(x);
F. void counter(int i) { counter( i); }
Answer: D,F
Question No: 42 – (Topic 1)
Given:
-
class A {
-
public void process() { System.out.print(quot;A,quot;); }
-
class B extends A {
-
public void process() throws IOException {
-
super.process();
-
System.out.print(quot;B,quot;);
-
throw new IOException();
18. }
-
public static void main(String[] args) {
-
try { new B().process(); }
-
catch (IOException e) { System.out.println(quot;Exceptionquot;); }
22. }
What is the result?
-
Exception
-
A,B,Exception
-
Compilation fails because of an error in line 20.
-
Compilation fails because of an error in line 14.
-
A NullPointerException is thrown at runtime.
Answer: D
Question No: 43 – (Topic 1)
Given:
-
public void go(int x) {
-
assert (x gt; 0);
-
switch(x) {
-
case 2: ;
-
default: assert false;
16. }
17. }
18. private void go2(int x) { assert (x lt; 0); } Which statement is true?
-
All of the assert statements are used appropriately.
-
Only the assert statement on line 12 is used appropriately.
-
Only the assert statement on line 15 is used appropriately.
-
Only the assert statement on line 18 is used appropriately.
-
Only the assert statements on lines 12 and 15 are used appropriately.
-
Only the assert statements on lines 12 and 18 are used appropriately.
-
Only the assert statements on lines 15 and 18 are used appropriately.
Answer: G
Question No: 44 – (Topic 1)
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: 45 – (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?
-
null
-
zero
-
some
-
Compilation fails.
-
An exception is thrown at runtime.
Answer: D
Question No: 46 – (Topic 1)
Given:
-
public class Test {
-
public static void main(String [] args) {
-
int x = 5;
-
boolean b1 = true;
-
boolean b2 = false; 16.
17. if ((x == 4) amp;amp; !b2 )
-
System.out.print(quot;1 quot;);
-
System.out.print(quot;2 quot;);
20. if ((b2 = true) amp;amp; b1 )
21. System.out.print(quot;3 quot;);
22. }
23. }
What is the result?
-
2
-
3
-
1 2
-
2 3
E. 1 2 3
-
Compilation fails.
-
An exception is thrown at runtime.
Answer: D
Question No: 47 – (Topic 1)
Given:
-
static void test() throws Error {
-
if (true) throw new AssertionError();
-
System.out.print(quot;test quot;);
14. }
-
public static void main(String[] args) {
-
try { test(); }
-
catch (Exception ex) { System.out.print(quot;exception quot;); }
-
System.out.print(quot;end quot;);
19. }
What is the result?
-
end
-
Compilation fails.
-
exception end
-
exception test end
-
A Throwable is thrown by main.
-
An Exception is thrown by main.
Answer: E
Question No: 48 – (Topic 1)
Given:
-
public class Foo {
-
static int[] a;
12. static { a[0]=2; }
13. public static void main( String[] args ) {}
14. }
Which exception or error will be thrown when a programmer attempts to run this code?
-
java.lang.StackOverflowError
-
java.lang.IllegalStateException
-
java.lang.ExceptionInInitializerError
-
java.lang.ArrayIndexOutOfBoundsException
Answer: C
Question No: 49 – (Topic 1)
Click the Exhibit button. Given:
-
try {
-
A a = new A();
-
a.method1();
-
} catch (Exception e) {
-
System.out.print(quot;an error occurredquot;);
30. }
Which two statements are true if a NullPointerException is thrown on line 3 of class C? (Choose two.)
-
The application will crash.
-
The code on line 29 will be executed.
-
The code on line 5 of class A will execute.
-
The code on line 5 of class B will execute.
-
The exception will be propagated back to line 27.
Answer: B,E
Question No: 50 – (Topic 1)
Given:
11. public static void main(String[] args) { 12. for (int i = 0; i lt;= 10; i ) {
13. if (i gt; 6) break;
14. }
15. System.out.println(i);
16. }
What is the result?
-
6
-
7
-
10
-
11
-
Compilation fails.
-
An exception is thrown at runtime.
Answer: E
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