Summer Special Limited Time 60% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 60certs

Oracle 1z0-809 Dumps

Page: 1 / 7
Total 196 questions

Java SE 8 Programmer II Questions and Answers

Question 1

Which class definition compiles?

Options:

A.

B.

C.

D.

Question 2

Given:

and the code fragment:

Which two code fragments, when inserted at line n1 independently, enable the code to print TruckCarBike?

Options:

A.

.sorted ((v1, v2) -> v1.getVId() < v2.getVId())

B.

.sorted (Comparable.comparing (Vehicle: :getVName)).reversed ()

C.

.map (v -> v.getVid()).sorted ()

D.

.sorted((v1, v2) -> Integer.compare(v1.getVId(), v2.getVid()))

E.

.sorted(Comparator.comparing ((Vehicle v) -> v.getVId()))

Question 3

Given:

interface Doable {

public void doSomething (String s);

}

Which two class definitions compile? (Choose two.)

Options:

A.

public abstract class Task implements Doable {public void doSomethingElse(String s) { }}

B.

public abstract class Work implements Doable {public abstract void doSomething(String s) { }public void doYourThing(Boolean b) { }}

C.

public class Job implements Doable {public void doSomething(Integer i) { }}

D.

public class Action implements Doable {public void doSomething(Integer i) { }public String doThis(Integer j) { }}

E.

public class Do implements Doable {public void doSomething(Integer i) { }public void doSomething(String s) { }public void doThat (String s) { }}

Question 4

You want to create a singleton class by using the Singleton design pattern.

Which two statements enforce the singleton nature of the design? (Choose two.)

Options:

A.

Make the class static.

B.

Make the constructor private.

C.

Override equals() and hashCode() methods of the java.lang.Object class.

D.

Use a static reference to point to the single instance.

E.

Implement the Serializable interface.

Question 5

Given:

and the command:

java Product 0

What is the result?

Options:

A.

An AssertionError is thrown.

B.

A compilation error occurs at line n1.

C.

New Price: 0.0

D.

A NumberFormatException is thrown at run time.

Question 6

Given:

and the code fragment:

What is the result?

Options:

A.

0.0

B.

1500.0

C.

A compilation error occurs.

D.

2000.0

Question 7

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!?

Options:

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 {

Question 8

Given the Greetings.properties file, containing:

and given:

What is the result?

Options:

A.

Compilation fails.

B.

GOODBY_MSG

C.

Hello, everyone!

D.

Goodbye everyone!

E.

HELLO_MSG

Question 9

Given the code fragment:

What is the result?

Options:

A.

Java EEJava EESE

B.

Java EESE

C.

The program prints either:Java EEJava SEorJava SEJava EE

D.

Java EEJava SE

Question 10

You have been asked to create a ResourceBundle which uses a properties file to localize an application.

Which code example specifies valid keys of menu1 and menu2 with values of File Menu and View Menu?

Options:

A.

File MenuView Menu

B.

menu1File Menumenu2View Menu

C.

menu1, File Menu, menu2, View Menu

D.

menu1 = File Menumenu2 = View Menu

Question 11

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 ()) {

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?

Options:

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.

Question 12

Given the records from the STUDENT table:

Given the code fragment:

Assume that the URL, username, and password are valid.

What is the result?

Options:

A.

The STUDENT table is not updated and the program prints:114 : John : john@uni.com

B.

The STUDENT table is updated with the record:113 : Jannet : jannet@uni.comand the program prints:114 : John : john@uni.com

C.

The STUDENT table is updated with the record:113 : Jannet : jannet@uni.comand the program prints:113 : Jannet : jannet@uni.com

D.

A SQLException is thrown at run time.

Question 13

Which two statements are true about synchronization and locks? (Choose two.)

Options:

A.

A thread automatically acquires the intrinsic lock on a synchronized statement when executed.

B.

The intrinsic lock will be retained by a thread if return from a synchronized method is caused by an uncaught exception.

C.

A thread exclusively owns the intrinsic lock of an object between the time it acquires the lock and the time it releases it.

D.

A thread automatically acquires the intrinsic lock on a synchronized method’s object when entering that method.

E.

Threads cannot acquire intrinsic locks on classes.

Question 14

Given the code fragment:

Map books = new TreeMap<>();

books.put (1007, “A”);

books.put (1002, “C”);

books.put (1003, “B”);

books.put (1003, “B”);

System.out.println (books);

What is the result?

Options:

A.

{1007=A, 1003=B, 1002=C}

B.

{1007=A, 1003=B, 1003=B, 1002=C}

C.

{1007=A, 1002=C, 1003=B, 1003=B}

D.

{1002=C, 1003=B, 1007=A}

Question 15

Given:

interface Rideable {Car getCar (String name); }

class Car {

private String name;

public Car (String name) {

this.name = name;

}

}

Which code fragment creates an instance of Car?

Options:

A.

Car auto = Car (“MyCar”): : new;

B.

Car auto = Car : : new;Car vehicle = auto : : getCar(“MyCar”);

C.

Rideable rider = Car : : new;Car vehicle = rider.getCar(“MyCar”);

D.

Car vehicle = Rideable : : new : : getCar(“MyCar”);

Question 16

Given:

What is the result?

Options:

A.

–catch--finally--dostuff-

B.

–catch-

C.

–finally--catch-

D.

–finally-dostuff--catch-

Question 17

Given the code fragment:

List values = Arrays.asList (1, 2, 3);

values.stream ()

.map(n -> n*2)//line n1

.peek(System.out::print)//line n2

.count();

What is the result?

Options:

A.

246

B.

The code produces no output.

C.

A compilation error occurs at line n1.

D.

A compilation error occurs at line n2.

Question 18

Given the code fragments:

and

What is the result?

Options:

A.

null

B.

A compilation error occurs.

C.

DogCatMouse

D.

[Dog, Cat, Mouse]

Question 19

Given:

public class Canvas implements Drawable {

public void draw () { }

}

public abstract class Board extends Canvas { }

public class Paper extends Canvas {

protected void draw (int color) { }

}

public class Frame extends Canvas implements Drawable {

public void resize () { }

}

public interface Drawable {

public abstract void draw ();

}

Which statement is true?

Options:

A.

Board does not compile.

B.

Paper does not compile.

C.

Frame does not compile.

D.

Drawable does not compile.

E.

All classes compile successfully.

Question 20

and the code fragment?

What is the result?

Options:

A.

$15.00

B.

15 $

C.

USD 15.00

D.

USD $15

Question 21

Given the code fragment:

What is the result?

Options:

A.

Word: why what when

B.

Word: why Word: why what Word: why what when

C.

Word: why Word: what Word: when

D.

Compilation fails at line n1.

Question 22

Given:

and the code fragment:

Which modification enables the code fragment to print Speaker?

Options:

A.

Implement Predicate in the Product.ProductFilter class and replace line n2 with .filter (p -> p.ProductFilter.test (p))

B.

Replace line n1 with:public static boolean isAvailable (Product p) {

C.

Replace line n2 with:.filter (p -> p.ProductFilter: :isAvailable (p))

D.

Replace line n2 with:.filter (p -> Product: :ProductFilter: :isAvailable ())

Question 23

Given:

What is the result?

Options:

A.

IT:null

B.

A NullPointerException is thrown at run time.

C.

A compilation error occurs.

D.

IT:0.0

Question 24

Given the content of /resourses/Message.properties:

welcome1=”Good day!”

and given the code fragment:

Properties prop = new Properties ();

FileInputStream fis = new FileInputStream (“/resources/Message.properties”);

prop.load(fis);

System.out.println(prop.getProperty(“welcome1”));

System.out.println(prop.getProperty(“welcome2”, “Test”));//line n1

System.out.println(prop.getProperty(“welcome3”));

What is the result?

Options:

A.

Good day!Testfollowed by an Exception stack trace

B.

Good day!followed by an Exception stack trace

C.

Good day!Testnull

D.

A compilation error occurs at line n1.

Question 25

Given:

public class Counter {

public static void main (String[ ] args) {

int a = 10;

int b = -1;

assert (b >=1) : “Invalid Denominator”;

int с = a / b;

System.out.println (c);

}

}

What is the result of running the code with the –ea option?

Options:

A.

-10

B.

0

C.

An AssertionError is thrown.

D.

A compilation error occurs.

Question 26

Given the code fragment:

BiFunction val = (t1, t2) -> t1 + t2; //line n1

//line n2

System.out.println(val.apply(10, 10.5));

What is the result?

Options:

A.

20

B.

20.5

C.

A compilation error occurs at line n1.

D.

A compilation error occurs at line n2.

Question 27

Given the code fragment:

LocalDate valentinesDay =LocalDate.of(2015, Month.FEBRUARY, 14);

LocalDate next15days = valentinesDay.plusDays (15);

LocalDate nextYear = next15days.plusYears(1); // line n1

System.out.println(nextYear);

What is the result?

Options:

A.

2016-03-01

B.

A DateTimeException is thrown.

C.

2016-02-29

D.

A compilation error occurs at line n1.

Question 28

Given the code fragment:

What is the result?

Options:

A.

[X][X, X][X, X, X][X, X, X, X]

B.

[X, X]

C.

[X][X, X][X, X, X]

D.

[X, X][X, X, X, X]

Question 29

Given:

class Vehicle {

int vno;

String name;

public Vehicle (int vno, String name) {

this.vno = vno,;

this.name = name;

}

public String toString () {

return vno + “:” + name;

}

}

and this code fragment:

Set vehicles = new TreeSet <> ();

vehicles.add(new Vehicle (10123, “Ford”));

vehicles.add(new Vehicle (10124, “BMW”));

System.out.println(vehicles);

What is the result?

Options:

A.

10123 Ford10124 BMW

B.

10124 BMW10123 Ford

C.

A compilation error occurs.

D.

A ClassCastException is thrown at run time.

Page: 1 / 7
Total 196 questions