Ensurepass

 

 

 

QUESTION 51

Given a java source file:

 

clip_image001[4]

 

What changes will make this code compile? (Select Two)

 

A.

Adding the public modifier to the declaration of class x

B.

Adding the protected modifier to the x() constructor

C.

Changing the private modifier on the declaration of the one() method to protected

D.

Removing the Y () constructor

E.

Removing the private modifier from the two () method

 

Correct Answer: CE

Explanation:

Using the private protected, instead of the private modifier, for the declaration of the one() method, would enable the two() method to access the one() method.

 

 

QUESTION 52

Given the for loop construct:

 

for ( expr1 ; expr2 ; expr3 ) {

 

statement;

 

}

 

Which two statements aretrue?

 

A.

This is not the only valid for loop construct; there exits another form of for loop constructor.

B.

The expression expr1 is optional. it initializes the loop and is evaluated once, as the loop begin.

C.

When expr2 evaluates to false, the loop terminates. It is evaluated only after each iteration through the loop.

D.

The expression expr3 must be present. It is evaluated after each iteration through the loop.

 

Correct Answer: BC

Explanation:

The for statement have this forms:

for (init-stmt;condition;next-stmt) {

body

}

There are three clauses in the for statement.

The init-stmt statement is done before the loop is started, usually to initialize an iteration variable.

The condition expression is tested before each time the loop is done. The loop isn’t executed if the boolean expression is false (the same as the while loop). The next-stmt statement is done after the body is executed. It typically increments an iteration variable.

 

 

QUESTION 53

Given:

 

clip_image003[4]

 

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

Explanation:

Note: The getClass methodReturns the runtime class of an object. ThatClassobject is the object that is locked bystatic synchronizedmethods of the represented class.

Note: Because Java handles objects and arrays by reference, classes and array types are known as reference types.

 

 

QUESTION 54

Given the code in a file Traveler.java:

 

clip_image005[4]

And the commands:

 

Javac Traveler.java

 

Java Traveler Java Duke

 

What is the result?

 

A.

Happy Journey! Duke

B.

Happy Journey! Java

C.

An exception is thrown at runtime

D.

The program fails to execute due to a runtime error

 

Correct Answer: D

 

 

QUESTION 55

Which two items can legally be contained within a java class declaration?

 

A.

An import statement

B.

A field declaration

C.

A package declaration

D.

A method declaration

 

Correct Answer: BD

Explanation:

http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

 

 

QUESTION 56

Given:

 

public class MyFor {

 

public static void main(String[] args) {

 

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

 

System.out.println(“ii = “+ ii);

 

ii = ii +1;

 

}

 

}

 

}

 

What is the result?

 

A.

ii = 0

ii = 2

B.

ii =0

ii = 1

ii = 2

ii = 3

C.

ii =

D.

Compilation fails.

 

Correct Answer: A

 

 

QUESTION 57

Given:

 

class Base {

 

public static void main(String[] args) {

 

System.out.println(“Base ” + args[2]);

 

}

 

}

 

public class Sub extends Base{

 

public static void main(String[] args) {

 

System.out.println(“Overriden ” + args[1]);

 

}

 

}

 

And the commands:

 

javac Sub.java

 

java Sub 10 20 30

 

What is the result?

 

A.

Base 30

B.

Overridden 20

C.

Overridden 20

Base 30

D.

Base 30

Overridden 20

 

Correct Answer: B

 

 

QUESTION 58

Which is a valid abstract class?

 

A.

public abstract class Car {

protected void accelerate();

}

B.

public interface Car {

protected abstract void accelerate();

}

C.

public abstract class Car {

protected final void accelerate();

}

D.

public abstract class Car {

protected abstract void accelerate();

}

E.

public abstract class Car {

protected abstract void accelerate() {

//more car can do

}}

 

Correct Answer: D

 

 

QUESTION 59

boolean log3 = ( 5.0 != 6.0) && ( 4 != 5);

 

boolean log4 = (4 != 4)|| (4 == 4);

 

System.out.println(“log3:”+ log3 + nlog4” + log4);

 

What is the result?

 

A.

log3:false

log4:true

B.

log3:true

log4:true

C.

log3:true

log4:false

D.

log3:false

log4:false

 

Correct Answer: B

 

 

QUESTION 60

Class StaticField {

 

static int i = 7;

 

public static void main(String[] args) {

 

StaticFied obj =new StaticField();

 

obj.i++;

 

StaticField.i++;

 

obj.i++;

 

System.out.println(StaticField.i + ” “+ obj.i);

 

}

 

}

 

What is the result?

 

A.

10 10

B.

8 9

C.

9 8

D.

7 10

 

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.