[Free] Download New Updated (October 2016) Oracle 1Z0-808 Real Exam 21-30

Ensurepass

QUESTION 21

Given the code fragment:

 

clip_image002

 

What is the result?

 

A.

Execution terminates in the first catch statement, and caught a RuntimeException is printed to the console.

B.

Execution terminates In the second catch statement, and caught an Exception is printed to the console.

C.

A runtime error is thrown in the thread “main”.

D.

Execution completes normally, and Ready to us?is printed to the console.

E.

The code fails to compile because a throws keyword is required.

 

Correct Answer: C

 

 

 

 

 

 

 

 

 

 

 

 

 

QUESTION 22

Given:

 

clip_image004

 

What is the result?

 

A.

200.0 : 100.0

B.

400.0 : 200.0

C.

400.0 : 100.0

D.

Compilation fails.

 

Correct Answer: C

 

 

QUESTION 23

Given:

 

clip_image006

 

Which two code fragments are valid?

 

clip_image008

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

 

Correct Answer: BC

Explanation:

When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class (C). However, if it does not, then the subclass must also be declared abstract (B).

Note: An abstract class is a class that is declared abstract–it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.

 

 

QUESTION 24

Given:

 

clip_image010

 

What is the result?

 

A.

10 20 30 40

B.

0 0 30 40

C.

Compilation fails

D.

An exception is thrown at runtime

 

Correct Answer: A

 

 

QUESTION 25

Given:

 

clip_image012

 

What is the result?

 

clip_image014

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: D

 

 

QUESTION 26

Given:

 

Class A { }

 

Class B { }

 

Interface X { }

 

Interface Y { }

 

Which two definitions of class C are valid?

A.

Class C extends A implements X { }

B.

Class C implements Y extends B { }

C.

Class C extends A, B { }

D.

Class C implements X, Y extends B { }

E.

Class C extends B implements X, Y { }

 

Correct Answer: AE

Explanation:

extends is for extending a class.

implements is for implementing an interface.

Java allows for a class to implement many interfaces.

 

 

QUESTION 27

Given the definitions of the MyString class and the Test class:

 

clip_image015

 

What is the result?

 

clip_image017

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: C

 

 

QUESTION 28

Given:

 

clip_image019

 

Which is true?

 

A.

Sum for 0 to 0 = 55

B.

Sum for 0 to 10 = 55

C.

Compilation fails due to error on line 6.

D.

Compilation fails due to error on line 7.

E.

An Exception is thrown at the runtime.

 

Correct Answer: D

Explanation:

Loop variables scope limited to that enclosing loop. So in this case, the scope of the loop variable x declared at line 5, limited to that for loop. Trying to access that variable at line 7, which is out of scope of the variable x, causes a compile time error. So compilation fails due to error at line 7. Hence option D is correct. Options A and B are incorrect, since code fails to compile. Reference: httpsy/docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html

 

 

QUESTION 29

You are developing a banking module. You have developed a class named ccMask that has a maskcc method.

 

Given the code fragment:

 

clip_image021

 

You must ensure that the maskcc method returns a string that hides all digits of the credit card number except the four last digits (and the hyphens that separate each group of four digits).

 

Which two code fragments should you use at line n1, independently, to achieve this requirement?

 

clip_image023

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: BC

 

 

QUESTION 30

Given the fragment:

 

String[][] arra = new String[3][];

 

arra[0] = new String[]{“rose”, “lily”};

 

arra[1] = new String[]{“apple”, “berry”,”cherry”,”grapes”};

 

arra[0] = new String[]{“beans”, “carrot”,”potato”};

 

// insert code fragment here

Which code fragment when inserted at line ‘// insert code fragment here’, enables the code to successfully change arra elements to uppercase?

 

A.

String[][] arra = new String[3][];

arra[0] = new String[]{“rose”, “lily”};

arra[1] = new String[]{“apple”, “berry”,”cherry”,”grapes”};

arra[0] = new String[]{“beans”, “carrot”,”potato”};

for (int i = 0; i < arra.length; i++) {

for (int j=0; j < arra[i].length; j++) {

arra[i][j] = arra[i][j].toUpperCase();

}

}

B.

for (int i = 0; i < 3; i++) {

for (int j=0; j < 4; j++) {

arra[i][j] = arra[i][j].toUpperCase();

}

}

C.

for (String a[]:arra[][]) {

for (String x:a[]) {

D.

toUpperCase();

}

}

E.

for (int i:arra.length) {

for (String x:arra) {

arra[i].toUpperCase();

}

}

 

Correct Answer: C

Explanation:

Incorrect:

not A: arra.length is 3, but the subarrays have 2, 3 and 4 elements. Index will be out of bound.

not B: The subarrys are of different lengths. Index will be out of bound.

not D: Compile error.

 

Free VCE & PDF File for Oracle 1Z0-808 Real Exam

Instant Access to Free VCE Files: CompTIA | VMware | SAP …
Instant Access to Free PDF Files: CompTIA | VMware | SAP …

This entry was posted in Uncategorized and tagged , . Bookmark the permalink.