Ensurepass

QUESTION 1

Which code fragment cause a compilation error?

 

A.

flat flt = 100F;

B.

float flt = (float) 1_11.00;

C.

float flt = 100;

D.

double y1 = 203.22;

floatflt = y1

E.

int y2 = 100;

floatflt = (float) y2;

 

< font face="Arial">Correct Answer: B

 

 

QUESTION 2

Given the code format:

 

clip_image002

 

Which code fragment must be inserted at line 6 to enable the code to compile?

 

A.

DBConfiguration f;

return f;

B.

Return DBConfiguration;

C.

Return new DBConfiguration;

D.

Retutn 0;

 

Correct Answer: B

 

 

QUESTION 3

Given the code fragment:

 

1. ArrayList<Integer> list = new ArrayList<>(1);

2. list.add(1001);

3. list.add(1002);

4. System.out.println(list.get(list.size()));

 

What is the result?

 

A.

Compilation fails due to an error on line 1.

B.

An exception is thrown at run time due to error on line 3

C.

Anexception is thrown at run time due to error on line 4

D.

1002

 

Correct Answer: C

Explanation:

The code compiles fine.

At runtime an IndexOutOfBoundsException is thrown when the second list item is added.

 

 

QUESTION 4

Given:

 

clip_image004

 

Which line causes a compilation error?

 

A.

line x1

B.

line x 2

C.

line x3

D.

line x4

 

Correct Answer: B

Explanation:

The variable x2 is used before it has been declared.

 

 

QUESTION 5

Given:

 

public class SampleClass {

 

public static void main(String[] args) {

 

AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new SampleClass();

 

sc = asc;

 

System.out.println(“sc: ” + sc.getClass());

 

System.out.println(“asc: ” + asc.getClass());

 

}}

 

class AnotherSampleClass extends SampleClass {

 

}

 

What is the result?

 

A.

sc: class Object

asc: class AnotherSampleClass

B.

sc: class SampleClass

asc: class AnotherSampleClass

C.

sc: class AnotherSampleClass

asc: class SampleClass

D.

sc: class AnotherSampleClass

asc: class AnotherSampleClass

 

Correct Answer: D

 

 

QUESTION 6

Given the code fragment:

 

System.out.println(2 + 4 * 9 – 3); //Line 21

 

System.out.println((2 + 4) * 9 – 3); // Line 22

 

System.out.println(2 + (4 * 9) – 3); // Line 23

 

System.out.println(2 + 4 * (9 – 3)); // Line 24

 

System.out.println((2 + 4 * 9) – 3); // Line 25

 

Which line of codes prints the highest number?

 

A.

Line 21

B.

Line 22

C.

Line 23

D.

Line 24

E.

Line 25

 

Correct Answer: B

Explanation:

The following is printed:

35

51

35

26

35

 

 

QUESTION 7

Which two are valid array declaration?

 

A.

Object array[];

B.

Boolean array[3];

C.

int[] array;

D.

Float[2] array;

 

Correct Answer: AC

 

 

QUESTION 8

Given the code fragment:

 

public static void main(String[] args) {

 

int iArray[] = {65, 68, 69};

 

iArray[2] = iArray[0];

 

iArray[0] = iArray[1];

 

iArray[1] = iArray[2];

 

for (int element : iArray) {

 

System.out.print(element + ” “);

 

}

 

A.

68, 65, 69

B.

68, 65, 65

C.

65,68, 65

D.

65, 68, 69

E.

Compilation fails

 

Correct Answer: B

 

 

QUESTION 9

Given the following code fragment:

 

clip_image006

 

What is the result if the integer value is 33?

 

A.

The fox jump lazy …

B.

The fox lazy …

C.

Quick fox over lazy …

D.

Quick fox the ….

 

Correct Answer: B

Explanation:

33 is greater than 0

33 is not equal to 0

the is printed

33 is greater than 30

fox is printed

33 is greater then 10 (the two else if are skipped) lazy is printed

finally … is printed.

 

 

QUESTION 10

Given:

 

clip_image007

 

Which two classes use the shape class correctly?

 

clip_image009

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

F.

Option F

 

Correct Answer: BE

Explanation:

When an abstract class is subclassed, the subclass usually provides implementations for all ofthe abstract methods in its parent class (E). 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.

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.