Ensurepass

 

QUESTION 21

Given:

 

import java.util.*;

 

public class Ref {

 

public static void main(String[] args) {

 

StringBuilder s1 = new StringBuilder(“Hello Java!”);

 

String s2 = s1.toString();

 

List<String> lst = new ArrayList<String>();

 

lst.add(s2);

 

System.out.println(s1.getClass());

 

System.out.println(s2.getClass());

 

System.out.println(lst.getClass());

 

}

 

}

 

What is the result?

 

A.

class java.lang.String

class java.lang.String

class java.util.ArrayList

B.

class java.lang.Object

class java.lang. Object

classjava.util.Collection

C.

class java.lang.StringBuilder

class java.lang.String

class java.util.ArrayList

D.

class java.lang.StringBuilder

class java.lang.String

class java.util.List

 

Correct Answer: C

Explanation:

class java.lang.StringBuilder

class java.lang.String

class java.util.ArrayList

 

 

QUESTION 22

Given:

 

public class Test {

 

public static void main(String[] args) {

 

int ax = 10, az = 30;

 

int aw = 1, ay = 1;

 

try {

 

aw = ax % 2;

 

ay = az / aw;

 

} catch (ArithmeticException e1) {

 

System.out.println(“Invalid Divisor”);

 

} catch (Exception e2) {

 

aw = 1;

 

System.out.println(“Divisor Changed”);

 

}

 

ay = az /aw; // Line 14

 

System.out.println(“Succesful Division ” + ay);

 

}

 

}

 

What is the result?

 

A.

Invalid Divisor

Divisor Changed

Successful Division 30

B.

Invalid Divisor

Successful Division 30

C.

Invalid Divisor

Exception in thread “main” java.lang.ArithmeticException: / by zero at test.Teagle.main(Teagle.java:14)

D.

Invalid Divisor

Exception in thread “main” java.lang.ArithmeticException: / by zero at test.Teagle.main(Teagle.java:14)

Successful Division 1

 

Correct Answer: C

 

 

QUESTION 23

Given:

 

clip_image002

 

What is the result?

 

A.

Null

B.

Compilation fails

C.

An exception is thrown at runtime

D.

0

 

Correct Answer: C

 

 

 

QUESTION 24

Given:

 

clip_image004

 

What three modifications, made independently, made to class greet, enable the code to compile and run?

 

A.

line 6 replaced with handy.dandy.keystroke stroke = new KeyStroke ( );

B.

line 6 replaced with handy.*.KeyStroke = new KeyStroke ( );

C.

line 6 replaced with handy.dandy.KeyStroke Stroke = new handy.dandy.KeyStroke();

D.

import handy.*; added before line 1

E.

import handy.dandy.*; added after line 1

F.

import handy.dandy,KeyStroke; added after line 1

G.

import handy.dandy.KeyStroke.typeException(); added before line 1

 

Correct Answer: CEF

Explanation:

Three separate solutions:

C: the full class path to the method must be stated (when we have not imported the package)

D: We can import the hold dandy class

F: we can import the specific method

 

 

 

 

 

 

 

 

 

 

 

 

QUESTION 25

Given:

 

clip_image005

 

A.

Ym

Xm2

B.

Ym

Xm1

C.

Compilation fails

D.

A ClassCastException is thrown at runtime

 

Correct Answer: B

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

QUESTION 26

Given:

 

clip_image006

 

What is the result?

 

A.

2 4 6 8 10 12

B.

2 4 6 8 10 12 14

C.

Compilation fails

D.

The program prints multiple of 2 infinite times

E.

The program prints nothing

 

Correct Answer: B

 

 

QUESTION 27

Which three are bad practices?

 

A.

Checking for ArrayIndexoutofBoundsException when iterating through an array to determine when all elements have been visited

B.

Checking for Error and. If necessary, restarting the programto ensure that users are unaware problems

C.

Checking for FileNotFoundException to inform a user that a filename entered is not valid

D.

Checking for ArrayIndexoutofBoundsException and ensuring that the program can recover if one occur

E.

Checking for anIOException and ensuring that the program can recover if one occurs

 

Correct Answer: ABD

 

 

 

 

 

 

 

 

QUESTION 28

Given the code fragment:

 

clip_image008

 

Which statement is true?

 

A.

After line 8, three objects are eligible for garbage collection

B.

After line 8, two objects are eligible for garbage collection

C.

After line 8, one object is eligible for garbage collection

D.

After line 8, none of the objects are eligible for garbage collection

 

Correct Answer: C

 

 

QUESTION 29

Given:

 

clip_image010

 

A.

a, e

i, o

B.

a, e

o, o

C.

e, e

I, o

D.

e, e

o, o

 

Correct Answer: B

 

 

QUESTION 30

Given the code fragment:

 

interface SampleClosable {

 

public void close () throws java.io.IOException;

 

}

 

Which three implementations are valid?

 

clip_image012

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

 

Correct Answer: ACE

Explanation:

A: Throwing the same exception is fine.

C: Using a subclass of java.io.IOException (here java.io.FileNotFoundException) is fine

E: Not using a throw clause is fine.

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.