Ensurepass

 

QUESTION 31

Given:

 

clip_image002

 

Which three lines will compile and output “right on!”?

 

A.

Line 5

B.

Line 6

C.

Line 7

D.

Line 8

E.

Line 9

F.

Line 10

 

Correct Answer: CDF

 

 

QUESTION 32

Given:

 

clip_image004

 

What is the result?

 

A.

null

B.

compilation fails

C.

Java.lang.NullPointerException

D.

0

 

Correct Answer: C

Explanation:

An array variable (here xx) can very well have the null value.

 

Note:

Null is the reserved constant used in Java to represent a void reference i.e a pointer to nothing. Internally it is just a binary 0, but in the high level Java language, it is a magic constant, quite distinct from zero, that internally could have any representation.

 

 

QUESTION 33

Given:

 

clip_image005

 

What code should be inserted?

 

clip_image007

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

F.

Option F

 

Correct Answer: C

Explanation:

Dog should be an abstract class. The correct syntax for this is: abstract class Dog { Poodle should extend Dog (not implement).

 

 

QUESTION 34

Given:

 

class Cake {

 

int model;

 

String flavor;

 

Cake() {

 

model = 0;

 

flavor = “Unknown”;

 

}

 

}

 

public class Test {

 

public static void main(String[] args) {

 

Cake c = new Cake();

 

bake1(c);

 

System.out.println(c.model + ” ” + c.flavor);

 

bake2(c);

 

System.out.println(c.model + ” ” + c.flavor);

 

}

 

public static Cake bake1(Cake c) {

 

c.flavor = “Strawberry”;

 

c.model = 1200;

 

return c;

}

 

public static void bake2(Cake c) {

 

c.flavor = “Chocolate”;

 

c.model = 1230;

 

return;

 

}

 

}

 

What is the result?

 

A.

0 unknown

0 unknown

B.

1200 Strawberry

1200 Strawberry

C.

1200 Strawberry

1230 Chocolate

D.

Compilation fails

 

Correct Answer: C

Explanation:

1200 Strawberry

1230 Chocolate

 

 

QUESTION 35

Given:

 

public class TestField {

 

int x;

 

int y;

 

public void doStuff(int x, int y) {

 

this.x = x;

 

y =this.y;

 

}

 

public void display() {

 

System.out.print(x + ” ” + y + ” : “);

 

}

 

public static void main(String[] args) {

 

TestField m1 = new TestField();

 

m1.x = 100;

 

m1.y = 200;

 

TestField m2 = new TestField();

 

m2.doStuff(m1.x, m1.y);

 

m1.display();

 

m2.display();

 

}

 

}

 

What is the result?

 

A.

100 200 : 100 200

B.

100 0 : 100 0 :

C.

100 200 : 100 0 :

D.

100 0 : 100 200 :

 

Correct Answer: C

 

 

QUESTION 36

Which three statements are benefits of encapsulation?

 

A.

Allowsa class implementation to change without changing t he clients

B.

Protects confidential data from leaking out of the objects

C.

Prevents code from causing exceptions

D.

Enables the class implementation to protect its invariants

E.

Permits classes to be combined into the same package

F.

Enables multiple instances of the same class to be created safely

 

Correct Answer: ABD

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

QUESTION 37

Given:

 

clip_image009

 

What is the result?

 

A.

x: 1 y: 2

B.

3 y: 4

C.

x: 0 y: 0

D.

3 y: 4

E.

x: 1 y: 2

F.

0 y: 0

G.

x: 0 y: 0

H.

0 y: 0

 

Correct Answer: C

 

 

QUESTION 38

Give:

 

Public Class Test {

 

}

 

Which two packages are automatically imported into the java source file by the java compiler?

 

A.

Java.lang

B.

Java.awt

C.

Java.util

D.

Javax.net

E.

Java.*

F.

The package with no name

 

Correct Answer: AF

Explan
ation:

For convenience, the Java compiler automatically imports three entire packages for each source file: (1) the package with no name, (2) the java.lang package, and (3) the current package (the package for the current file).

 

Note: Packages in the Java language itself begin withjava.orjavax.

 

 

QUESTION 39

Given the fragment:

 

clip_image011

 

What is the result?

 

A.

13480.0

B.

13480.02

C.

Compilation fails

D.

An exception is thrown at runtime

 

Correct Answer: A

 

 

QUESTION 40

The catch clause argument is always of type__________.

 

A.

Exception

B.

Exception but NOT including RuntimeException

C.

Throwable

D.

RuntimeException

E.

CheckedException

F.

Error

 

Correct Answer: C

Explanation:

Because all exceptions in Java are the sub-class ofjava.lang.Exceptionclass, you can have a singlecatch blockthat catches an exception of typeExceptiononly. Hence the compiler is fooled into thinking that this block canhandle any exception.

See the following example:

 

try

{

// …

}

catch(Exception ex)

{

// Exception handling code for ANY exception

}

 

You can also use the java.lang.Throwable class here, since Throwable is the parent class for the application-specificException classes. However, this is discouraged in Java programming circles. This is because Throwable happens to also be the parent class for the non-application specific Error classes which are not meant to be handled explicitly as they are catered forby the JVM itself.

 

Note: The Throwable class is the superclass of all errors and exceptions in the Java language. Only objects that are instances of this class (or one of its subclasses) are thrown by the Java Virtual Machine or can be thrown by the Java throw statement. A throwable contains a snapshot of the execution stack of its thread at the time it was created. It can also contain a message string that gives more information about the error.

 

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.