Ensurepass

 

QUESTION 81

public class Two {

 

public static void main(String[] args) {

 

try {

 

doStuff();

 

system.out.println(“1”);

 

}

 

catch {

 

system.out.println(“2”);

 

}}

 

public static void do Stuff() {

 

if (Math.random() > 0.5) throw new RunTimeException(); doMoreStuff();

 

System.out.println(“3 “);

 

}

 

public static void doMoreStuff() {

 

System.out.println(“4”);

 

}

 

}

 

Which two are possible outputs?

 

A.

2

B.

4

3

1

C.

1

D.

1

2

 

Correct Answer: AB

Explanation:

A: Output is 2 if Math.random() is greater than 0.5.

B: If Math.random() returns a value less equal to 0.5, the code won’t throw an exception, it will continue with the doMore() method which will println “4” after which the program will continue with the doStuff() method and will println “3”, after that we will be back in main() and the program will print “1”.

 

 

QUESTION 82

Given:

 

clip_image002

What is the result?

 

A.

Compilation fails

B.

An exception is thrown at runtime

C.

There is no result because this is not correct way to determine the hash code

D.

Hash is: 111111, 44444444, 999999999

 

Correct Answer: A

Explanation:

The compilation fails as SampleClassA and SampleClassB cannot overrideSampleClass because the return type of SampleClass is int, while the return type of SampleClassA and SampleClassB is long.

 

Note: If all three classes had the same return type the output would be:

Hash is: 111111, 44444444, 999999999

 

 

QUESTION 83

Given the fragment:

&
nbsp;

clip_image004

 

What is the result?

 

A.

14

B.

15

C.

24

D.

25

E.

34

F.

35

 

Correct Answer: F

Explanation:

The two elements 3 and 4 (starting from position with index 2) are copied into position index 1 and 2 in the same array.

Afterthe arraycopy command the array looks like:

{1, 3, 4, 4, 5};

 

Then element with index 1 is printed: 3

Then element with index 4 is printed: 5

 

Note: The System class has an arraycopy method that you can use to efficiently copy data from one array into another:

public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)

The two Object arguments specify the array to copyfromand the array to copyto. The three int arguments specify the starting position in the source array, the starting position in the destination array, and the number of array elements to copy.

 

 

QUESTION 84

A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the results?

 

A.

Compilation fails.

B.

The third argument is given the value null.

C.

The third argument is given the value void.

D.

The third argument is given the value zero.

E.

The third argument is given the appropriate falsy value for its declared type. F) An exception occurs when the method attempts to access the third argument.

 

Correct Answer: A

 

 

QUESTION 85

Given the following four Java file definitions:

 

// Foo.java

 

package facades;

 

public interface Foo { }

 

// Boo.java

 

package facades;

 

public interface Boo extends Foo { }

 

// Woofy.java

 

package org.domain

 

// line n1

 

public class Woofy implements Boo, Foo {}

 

// Test.java

 

package.org;

 

public class Test {

 

public static void main(String[] args) {

 

Foo obj=new Woofy();

 

Which set modifications enable the code to compile and run?

 

A.

At line n1, Insert: import facades;At line n2, insert:import facades;importorg.domain;

B.

At line n1, Insert: import facades.*;At line n2, insert:import facades;import org.*;

C.

At line n1, Insert: import facades.*;At line n2, insert:import facades.Boo;import org.*;

D.

At line n1, Insert: import facades.Foo, Boo;At line n2, insert:import org.domain.Woofy;

E.

At line n1, Insert: import facades.*;At line n2, insert:import facades;import org.domain.Woofy;

Correct Answer: E

 

 

QUESTION 86

Which two statements are true?

 

A.

An abstract class can implement an interface.

B.

An abstract class can be extended by an interface.

C.

An interface CANNOT be extended by another interface.

D.

An interface can be extended by an abstract class.

E.

An abstract class can be extended by a concrete class.

F.

An abstract class CANNOT be extended by an abstract class.

 

Correct Answer: AE

Explanation:

http://docs.oracle.com/javase/tutorial/java/IandI/abstract.html

 

 

QUESTION 87

Given:

 

clip_image006

 

What is the result?

 

A.

The sum is 2

B.

The sum is 14

C.

The sum is 15

D.

The loop executes infinite times

E.

Compilation fails

 

Correct Answer: E

 

 

 

 

 

 

 

 

 

 

 

QUESTION 88

Given:

 

clip_image008

 

What is the result?

 

A.

Initialized

Started

B.

Initialized

Started

Initialized

C.

Compilation fails

D.

An exception is thrown at runtime

 

Correct Answer: B

 

 

QUESTION 89

Given the code fragment:

 

clip_image010

What is the result?

 

A.

10 8 6 4 2 0

B.

10 8 6 4 2

C.

AnArithmeticException is thrown at runtime

D.

The program goes into an infinite loop outputting: 10 8 6 4 2 0. . .

E.

Compilation fails

 

Correct Answer: B

 

 

QUESTION 90

Given the fragments:

 

clip_image012

 

Which line causes a compilation error?

 

A.

Line n1

B.

Line n2

C.

Line n3

D.

Line n4

 

Correct Answer: A

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

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

 

 

 

 

 

 

 

 

 

 

Comments are closed.