Weekend Special 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: sale65best

How to Pass the Oracle 1z0-809 Exam: Comprehensive Java SE 8 Programmer II Guide and Tips

Questions 21

Given the records from the STUDENT table:

1z0-809 Question 21

Given the code fragment:

1z0-809 Question 21

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.

Oracle 1z0-809 Premium Access
Questions 22

Given:

1z0-809 Question 22

Which two interfaces can you use to create lambda expressions? (Choose two.)

Options:
A.

T

B.

R

C.

P

D.

S

E.

Q

F.

U

Questions 23

Given the code fragment:

List nums = Arrays.asList (10, 20, 8):

System.out.println (

//line n1

);

Which code fragment must be inserted at line n1 to enable the code to print the maximum number in the nums list?

Options:
A.

nums.stream().max(Comparator.comparing(a -> a)).get()

B.

nums.stream().max(Integer : : max).get()

C.

nums.stream().max()

D.

nums.stream().map(a -> a).max()

Questions 24

Given the code fragment:

public class Foo {

public static void main (String [ ] args) {

Map unsortMap = new HashMap< > ( );

unsortMap.put (10, “z”);

unsortMap.put (5, “b”);

unsortMap.put (1, “d”);

unsortMap.put (7, “e”);

unsortMap.put (50, “j”);

Map treeMap = new TreeMap (new

Comparator ( ) {

@Override public int compare (Integer o1, Integer o2) {return o2.compareTo

(o1); } } );

treeMap.putAll (unsortMap);

for (Map.Entry entry : treeMap.entrySet () ) {

System.out.print (entry.getValue () + “ “);

}

}

}

What is the result?

Options:
A.

A compilation error occurs.

B.

d b e z j

C.

j z e b d

D.

z b d e j

Questions 25

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?

Options:
A.

User is registered.

B.

An AgeOutOfLimitException is thrown.

C.

A UserException is thrown.

D.

A compilation error occurs in the main method.

Questions 26

Which statement is true about the single abstract method of the java.util.function.Function interface?

Options:
A.

It accepts one argument and returns void.

B.

It accepts one argument and returns boolean.

C.

It accepts one argument and always produces a result of the same type as the argument.

D.

It accepts an argument and produces a result of any data type.

Questions 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.

Questions 28

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.id = = b.id) {

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?

Options:
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));

Questions 29

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) throws 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?

Options:
A.

The program prints:Run RunnerCall Caller : nullAnd the program does not terminate.

B.

The program terminates after printing:Run RunnerCall Caller : Run

C.

A compilation error occurs at line n1.

D.

An Execution is thrown at run time.

Questions 30

Given that these files exist and are accessible:

/sports/info.txt

/sports/cricket/players.txt

/sports/cricket/data/ODI.txt

and given the code fragment:

int maxDepth =2;

Stream paths = Files.find(Paths.get(“/sports”),

maxDepth,

(p, a) -> p.getFileName().toString().endsWith (“txt”),

FileVisitOption.FOLLOW_LINKS);

Long fCount = paths.count();

System.out.println(fCount);

Assuming that there are NO soft-link/symbolic links to any of the files in the directory structure, what is the result?

Options:
A.

1

B.

2

C.

3

D.

An Exception is thrown at runtime.

Exam Code: 1z0-809
Certification Provider: Oracle
Exam Name: Java SE 8 Programmer II
Last Update: Jan 15, 2025
Questions: 196