Leads4pass > Oracle > Oracle Database > 1Z0-809 > 1Z0-809 Online Practice Questions and Answers

1Z0-809 Online Practice Questions and Answers

Questions 4

Given:

class Book {

int id;

String name;

public Book (int id, String name) {

this.id = id;

this.name = name;

}

public boolean equals (Object obj) { //line n1

boolean output = false;

Book b = (Book) obj;

if (this.name.equals(b name))}

output = true;

}

return output;

}

}

and the code fragment:

Book b1 = new Book (101, "Java Programing");

Book b2 = new Book (102, "Java Programing");

System.out.println (b1.equals(b2)); //line n2

Which statement is true?

A. The program prints true.

B. The program prints false.

C. A compilation error occurs. To ensure successful compilation, replace line n1 with: boolean equals (Book obj) {

D. A compilation error occurs. To ensure successful compilation, replace line n2 with: System.out.println (b1.equals((Object) b2));

Buy Now
Questions 5

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?

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.

Buy Now
Questions 6

Given:

Your design requires that:

fuelLevel of Engine must be greater than zero when the start() method is invoked. The code must terminate if fuelLevel of Engine is less than or equal to zero.

Which code fragment should be added at line n1 to express this invariant condition?

A. assert (fuelLevel) : "Terminating...";

B. assert (fuelLevel > 0) : System.out.println ("Impossible fuel");

C. assert fuelLevel < 0: System.exit(0);

D. assert fuelLevel > 0: "Impossible fuel" ;

Buy Now
Questions 7

Given:

and

Which interface from the java.util.function package should you use to refactor the class Txt?

A. Consumer

B. Predicate

C. Supplier

D. Function

Buy Now
Questions 8

Assume customers.txt is accessible and contains multiple lines.

Which code fragment prints the contents of the customers.txt file?

A. Stream stream = Files.find (Paths.get ("customers.txt")); stream.forEach((String c) -> System.out.println(c));

B. Stream stream = Files.find (Paths.get ("customers.txt")); stream.forEach( c) -> System.out.println(c));

C. Stream stream = Files.list (Paths.get ("customers.txt")); stream.forEach( c) -> System.out.println(c));

D. Stream lines = Files.lines (Paths.get ("customers.txt")); lines.forEach( c) -> System.out.println(c));

Buy Now
Questions 9

Given that data.txt and alldata.txt are accessible, and the code fragment: What is required at line n1 to enable the code to overwrite alldata.txt with data.txt?

A. br.close();

B. bw.writeln();

C. br.flush();

D. bw.flush();

Buy Now
Questions 10

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 FuelNotAvailException { //line n2 super ride (); } }

and the code fragment:

public static void main (String[] args) throws Exception { Vehicle v = new SolarVehicle ();

A. ride(); } Which modification enables the code fragment to print Happy Journey!?

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

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

D. Replace line n2 with void ride() throws Exception {

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

Buy Now
Questions 11

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

abstract void open ();

}

public interface Drawable {

public abstract void draw ();

}

Which statement is true?

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.

Buy Now
Questions 12

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?

A. 2016-03-01

B. A DateTimeException is thrown.

C. 2016-02-29

D. A compilation error occurs at line n1.

Buy Now
Questions 13

Given the code fragment:

public void recDelete (String dirName) throws IOException {

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

if (listOfFiles ! = null andand 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?

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.

Buy Now
Exam Code: 1Z0-809
Exam Name: Java SE 8 Programmer II
Last Update:
Questions: 207
10%OFF Coupon Code: SAVE10

PDF (Q&A)

$49.99

VCE

$55.99

PDF + VCE

$65.99