Ensurepass
2017 July Oracle Official New Released 1Z0-809 Q&As
100% Free Download! 100% Pass Guaranteed!
http://www.ensurepass.com/1Z0-809.html

Java SE 8 Programmer II

QUESTION 21

Given:

 

clip_image002

 

A.

X X X

B.

X Y X

C.

Y Y X

D.

Y YY

 

Correct Answer: D

QUESTION 22

Given the code fragment:

 

public static void main (String [ ] args) throws IOException {

 

BufferedReader br = new BufferedReader (new InputStremReader (System.in));

 

System.out.print (“Enter GDP: “);

 

//line 1

 

}

 

Which code fragment, when inserted at line 1, enables the code to read the GDP from the user?

 

A.

int GDP = Integer.parseInt (br.readline());

B.

int GDP = br.read();

C.

int GDP = br.nextInt();

D.

int GDP = Integer.parseInt (br.next());

 

Correct Answer: C

 

 

QUESTION 23

Given:

 

class UserException extends Exception { }

 

class AgeOutOfLimitException extends UserException { }

 

and the code fragment:

 

class App {

 

public void doRegister(String name, int age)

 

throws UserException, AgeOutOfLimitException {

 

if (name.length () < 6) {

 

throw new UserException ();

 

} else if (age >= 60) {

 

throw new AgeOutOfLimitException ();

 

} else {

 

System.out.println(“User is registered.”);

 

}

 

}

 

public static void main(String[ ] args) throws UserException {

App t = new App ();

 

t.doRegister(“Mathew”, 60);

 

}

 

}

 

What is the result?

 

A.

User is registered.

B.

An AgeOutOfLimitException is thrown.

C.

A UserException is thrown.

D.

A compilation error occurs in the main method.

 

Correct Answer: A

 

 

QUESTION 24

Which statement is true about java.time.Duration?

 

A.

It tracks time zones.

B.

It preserves daylight saving time.

C.

It defines time-based values.

D.

It defines date-based values.

 

Correct Answer: C

Explanation:

http://tutorials.jenkov.com/java-date-time/duration.html#accessing-the-time-of-a-duration

 

 

QUESTION 25

Given the code fragment:

 

public void recDelete (String dirName) throws IOException {

 

File [ ] listOfFiles = new File (dirName) .listFiles();

 

if (listOfFiles ! = null && listOfFiles.length >0) {

 

for (File aFile : listOfFiles) {

 

if (aFile.isDirectory ()) {

 

recDelete (aFile.getAbsolutePath ());

 

} else {

 

if (aFile.getName ().endsWith (“.class”))

 

aFile.delete ();

 

}

 

}

}

 

}

 

Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is invoked.

 

What is the result?

 

A.

The method deletes all the .class files in the Projects directory and its subdirectories.

B.

The method deletes the .class files of the Projects directory only.

C.

The method executes and does not make any changes to the Projects directory.

D.

The method throws an IOException.

 

Correct Answer: B

 

 

QUESTION 26

Given the code fragment:

 

class CallerThread implements Callable<String> {

 

String str;

 

public CallerThread(String s) {this.str=s;}

 

public String call() throws Exception {

 

return str.concat(“Call”);

 

}

 

}

 

and

 

public static void main (String[] args) throws InterruptedException, ExecutionException

 

{

 

ExecutorService es = Executors.newFixedThreadPool(4
); //line n1

 

Future f1 = es.submit (newCallerThread(“Call”));

 

String str = f1.get().toString();

 

System.out.println(str);

 

}

 

Which statement is true?

 

A.

The program prints Call Call and terminates.

B.

The program prints Call Call and does not terminate.

C.

A compilation error occurs at line n1.

D.

An ExecutionException is thrown at run time.

 

Correct Answer: B

 

 

QUESTION 27

Given the for loop construct:

 

for ( expr1 ; expr2 ; expr3 ) {

 

statement;

 

}

 

Which two statements are true?

 

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 28

Given:

 

clip_image004

What is the result?

 

A.

100

B.

Compilation fails due to an error in line n1

C.

Compilation fails due to an error at line n2

D.

Compilation fails due to an error at line n3

 

Correct Answer: C

 

 

QUESTION 29

Given:

 

class FuelNotAvailException extends Exception { }

 

class Vehicle {

 

void ride() throws FuelNotAvailException {//line n1

 

System.out.println(“Happy Journey!”);

 

}

 

}

 

class SolarVehicle extends Vehicle {

 

public void ride () throws Exception {//line n2

 

super ride ();

 

}

 

}

 

and the code fragment:

 

public static void main (String[] args) throws FuelNotAvailException, Exception {

 

Vehicle v = new SolarVehicle ();

 

v.ride();

 

}

 

Which modification enables the code fragment to print Happy Journey!?

 

A.

Replace line n1 with public void ride() throws FuelNotAvailException {

B.

Replace line n1 with protected void ride() throws Exception {

C.

Replace line n2 with void ride() throws Exception {

D.

Replace line n2 with private void ride() throws FuelNotAvailException {

 

Correct Answer: B

 

 

QUESTION 30

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”);

 

}

 

void doStuff2() {

 

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

100% Free Download!
—Download Free Demo:1Z0-809 Demo PDF
100% Pass Guaranteed!
Download 2017 Ensurepass 1Z0-809 Full Exam PDF and VCE Q&As:128
—Get 10% off your purchase! Copy it:TJDN-947R-9CCD [2017.07.01-2017.07.31]

Ensurepass ExamCollection Testking
Lowest Price Guarantee Yes No No
Up-to-Dated Yes No No
Real Questions Yes No No
Explanation Yes No No
PDF + VCE Yes No No
Free VCE Simulator Yes No No
Instant Download Yes No No

2017 Ensurepass IT Certification PDF and VCE