Pass4itsure > Oracle > Oracle Certifications > 1Z0-809 > 1Z0-809 Online Practice Questions and Answers

1Z0-809 Online Practice Questions and Answers

Questions 4

Given the code fragment:

Path file = Paths.get ("courses.txt"); // line n1

Assume the courses.txt is accessible.

Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?

A. List fc = Files.list(file); fc.stream().forEach (s - > System.out.println(s));

B. Stream fc = Files.readAllLines (file); fc.forEach (s - > System.out.println(s));

C. List fc = readAllLines(file); fc.stream().forEach (s - > System.out.println(s));

D. Stream fc = Files.lines (file); fc.forEach (s - > System.out.println(s));

Buy Now
Questions 5

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 6

Given the code fragments:

class Caller implements Callable {

String str;

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

public String call()throws Exception { return str.concat ("Caller");}

}

class Runner implements Runnable {

String str;

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

public void run () { System.out.println (str.concat ("Runner"));}

}

and

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

ExecutorService es = Executors.newFixedThreadPool(2);

Future f1 = es.submit (new Caller ("Call"));

Future f2 = es.submit (new Runner ("Run"));

String str1 = (String) f1.get();

String str2 = (String) f2.get(); //line n1

System.out.println(str1+ ":" + str2);

}

What is the result?

A. The program prints: Run Runner Call Caller : null And the program does not terminate.

B. The program terminates after printing: Run Runner Call Caller : Run

C. A compilation error occurs at line n1.

D. An Execution is thrown at run time.

Buy Now
Questions 7

Given:

and the code fragment:

What is the result?

A. true true

B. false true

C. false false

D. true false

Buy Now
Questions 8

Given the code fragment: Assume that the value of now is 6:30 in the morning. What is the result?

A. An exception is thrown at run time.

B. 0

C. 60

D. 1

Buy Now
Questions 9

Given the code fragments: and

What is the result?

A. Video played.Game played.

B. A compilation error occurs.

C. class java.lang.Exception

D. class java.io.IOException

Buy Now
Questions 10

Given records from the Player table:

and given the code fragment:

try {

Connection conn = DriverManager.getConnection(URL, username, password);

Statement st= conn.createStatement(

ResultSet.TYPE_SCROLL_SENSITIVE,

ResultSet.CONCUR_UPDATABLE);

st.execute ("SELECT * FROM Player");

st.setMaxRows(2);

ResultSet rs = st.getResultSet();

rs.absolute(3);

while (rs.next ()) {

System.out.println(rs.getInt(1) + " " + rs.getString(2));

}

} catch (SQLException ex) {

System.out.print("SQLException is thrown.");

}

Assume that:

The required database driver is configured in the classpath.

The appropriate database is accessible with URL, username, and password.

The SQL query is valid.

What is the result?

A. 2 Jack 3 Sam

B. The program prints nothing.

C. 3 Sam

D. SQLException is thrown.

Buy Now
Questions 11

Given the code fragments:

interface CourseFilter extends Predicate { public default boolean test (String str) {

return str.contains ("Java");

}

}

and

List strs = Arrays.asList("Java", "Java EE", "Embedded Java");

Predicate cf1 = s - > s.length() > 3;

Predicate cf2 = new CourseFilter() { //line n1

public boolean test (String s) {

return s.startsWith ("Java");

}

};

long c = strs.stream()

.filter(cf1)

.filter(cf2 //line n2

.count();

System.out.println(c);

What is the result?

A. 2

B. 3

C. A compilation error occurs at line n1.

D. A compilation error occurs at line n2.

Buy Now
Questions 12

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?

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}

Buy Now
Questions 13

Given the code fragment:

Stream files = Files.list(Paths.get(System.getProperty("user.home"))); files.forEach (fName -> { //

line n1

try {

Path aPath = fName.toAbsolutePath(); //line n2

System.out.println(fName + ":"

+ Files.readAttributes(aPath, Basic.File.Attributes.class).creationTime

());

} catch (IOException ex) {

ex.printStackTrace();

});

What is the result?

A. All files and directories under the home directory are listed along with their attributes.

B. A compilation error occurs at line n1.

C. The files in the home directory are listed along with their attributes.

D. A compilation error occurs at line n2.

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

PDF (Q&A)

$49.99

VCE

$55.99

PDF + VCE

$65.99