Ensurepass

 

QUESTION 141

Give:

 

clip_image002

 

What value should replacekkin line x to cause jj = 5 to be output?

 

A.

-1

B.

1

C.

5

D.

8

E.

11

 

Correct Answer: E

Explanation:

We need to get jj to 5. It is initially set to 0. So we need to go through the for loop 5 times. The for loops ends when ii > 6 and ii decreases for every loop. So we need to initially set ii to 11. We set kk to 11.

 

 

QUESTION 142

Which two may precede the word `class’ in a class declaration?

 

A.

local

B.

public

C.

static

D.

volatile

E.

synchronized

 

Correct Answer: BC

Explanation:

B: A class can be declared as public or private.

C: You can declare two kinds of classes: top-level classes and inner classes. You define an inner class within a top-level class.Depending on how it is defined, an inner class can be one of the following four types:Anonymous, Local, Member and Nested top-level.

A nested top-level class is a member classes with astaticmodifier. A nested top-level class is just like any other top-level class except that it is declared within another class or interface. Nested top-level classes are typically used as a convenient way to group related classes without creating a new package.

The following is an example:

 

public class Main {

staticclass Killer {

 

 

QUESTION 143

Given:

 

clip_image004

 

Which code fragment, when inserted at line 14, enables the code to print Mike Found?

 

A.

int f = ps.indexOf {new patient (“Mike”)};

B.

int f = ps.indexOf (patient(“Mike”));

C.

patient p = new Patient (“Mike”);

int f = pas.indexOf(P)

D.

int f = ps.indexOf(p2);

 

Correct Answer: C

 

 

QUESTION 144

1. class StaticMethods {

 

2. static void one() {

 

3. two();

 

4. StaticMethods.two();

 

5. three();

 

6. StaticMethods.four();

7. }

 

8. static void two() { }

 

9. void three() {

 

10. one();

 

11. StaticMethods.two();

 

12. four();

 

13. StaticMethods.four();

 

14. }

 

15. void four() { }

 

16. }

 

Which three lines are illegal?

 

A.

line 3

B.

line 4

C.

line 5

D.

line 6

E.

line 10

F.

line 11

G.

line 12

H.

line 13

 

Correct Answer: CDH

 

 

QUESTION 145

Given:

 

clip_image005

 

Which two code fragments are valid?

 

clip_image007

 

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, thenthe 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 146

Given:

 

public class ScopeTest {

 

int j, int k;

 

public static void main(String[] args) {

 

ew ScopeTest().doStuff(); }

 

void doStuff() {

 

nt x = 5;

 

oStuff2();

 

System.out.println(“x”);

 

}

 

voiddoStuff2() {

 

nt y = 7;

 

ystem.out.println(“y”);

 

or (int z = 0; z < 5; z++) {

 

ystem.out.println(“z”);

 

ystem.out.println(“y”);

 

}

 

Which two items are fields?

 

A.

j

B.

k

C.

x

D.

y

E.

z

 

Correct Answer: AB

 

 

QUESTION 147

Given:

 

clip_image008

 

What is true about the class Wow?

 

A.

It compiles without error.

B.

It does not compile because an abstract class cannot have private methods.

C.

It does not compile because an abstract class cannot have instance variables.

D.

It does not compile because an abstract class must have at least one abstract method.

E.

It does not compile because an abstract class must have a constructor with no arguments.

 

Correct Answer: A

 

 

 

 

QUESTION 148

Given:

 

class X {}

 

class Y { Y ( ) { } }

 

class Z { Z (int i ) { } }

 

Which class has a default constructor?

 

A.

X only

B.

Y only

C.

Z only

D.

X and Y

E.

Y and Z

F.

X and Z

G.

X, Y and Z

 

Correct Answer: A

 

 

QUESTION 149

Given:

 

public class Test {

 

static boolean bVar;

 

public static void main(String[] args) {

 

boolean bVar1 = true;

 

int count =8;

 

do {

 

System.out.println(“Hello Java! ” +count);

 

if (count >= 7) {

 

bVar1 = false;

 

}

 

} while (bVar != bVar1 && count > 4);

 

count -= 2;

 

}

 

}

 

What isthe result?

 

A.

Hello Java! 8

Hello Java! 6

Hello Java! 4

B.

Hello Java! 8

Hello Java! 6

C.

Hello Java! 8

D.

Compilation fails

 

Correct Answer: C

Explanation:

Hello Java! 8

 

 

QUESTION 150

Given the code fragment:

 

System.out.printIn(“Result: ” + 2 + 3 + 5);

 

System.out.printIn(“Result: ” + 2 + 3 * 5);

 

What is theresult?

 

A.

Result: 10

Result: 30

B.

Result: 10

Result: 25

C.

Result: 235

Result: 215

D.

Result: 215

Result: 215

E.

Compilation fails

 

Correct Answer: C

Explanation:

First line:

System.out.println(“Result: ” + 2 + 3 + 5);

String concatenation is produced.

 

Second line:

System.out.println(“Result: ” + 2 + 3 * 5);

3*5 is calculated to 15 and is appended to string 2. Result 215.

 

The output is:

Result: 235

Result: 215

 

Note #1:

To produce an arithmetic result, the following code would have to be used:

 

System.out.println(“Result: ” + (2 + 3 + 5));

System.out.println(“Result: ” + (2 + 1 * 5));

 

run:

Result: 10

Result: 7

 

Note #2:

If the code was as follows:

 

System.out.println(“Result: ” + 2 + 3 + 5″);

System.out.println(“Result: ” + 2 + 1 * 5″);

 

The compilation would fail. There is an unclosed string literal, 5″, on each line.

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.