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

1Z0-809 Online Practice Questions and Answers

Questions 4

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?

A. -10

B. 0

C. An AssertionError is thrown.

D. A compilation error occurs.

Buy Now
Questions 5

Given:

class Bird {

public void fly () { System.out.print("Can fly"); }

}

class Penguin extends Bird {

public void fly () { System.out.print("Cannot fly"); }

}

and the code fragment:

class Birdie {

public static void main (String [ ] args) {

fly( ( ) -> new Bird ( ));

fly (Penguin : : new);

}

/* line n1 */

}

Which code fragment, when inserted at line n1, enables the Birdie class to compile?

A. static void fly (Consumer bird) { bird :: fly (); } {

B. static void fly (Consumer bird) bird.accept( ) fly (); } {

C. static void fly (Supplier bird) bird.get( ) fly (); } {

D. static void fly (Supplier bird) LOST

Buy Now
Questions 6

Given that course.txt is accessible and contains:

Course : : Java

and given the code fragment:

public static void main (String[ ] args) { int i; char c; try (FileInputStream fis = new FileInputStream (“course.txt”);

InputStreamReader isr = new InputStreamReader(fis);) {

while (isr.ready()) { //line n1

isr.skip(2);

i = isr.read ();

c = (char) i;

System.out.print(c);

} } catch (Exception e) { e.printStackTrace(); } }

What is the result?

A. ur :: va

B. ueJa

C. The program prints nothing.

D. A compilation error occurs at line n1.

Buy Now
Questions 7

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?

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

Buy Now
Questions 8

Which statement is true about java.util.stream.Stream?

A. A stream cannot be consumed more than once.

B. The execution mode of streams can be changed during processing.

C. Streams are intended to modify the source data.

D. A parallel stream is always faster than an equivalent sequential stream.

Buy Now
Questions 9

Given the code fragment:

List list1 = Arrays.asList(10, 20); List list2 = Arrays.asList(15, 30); //line n1

Which code fragment, when inserted at line n1, prints 10 20 15 30?

A. Stream.of(list1, list2) .flatMap(list -> list.stream()) .forEach(s -> System.out.print(s + " "));

B. Stream.of(list1, list2) .flatMap(list -> list.intStream()) .forEach(s -> System.out.print(s + " "));

C. list1.stream() .flatMap(list2.stream().flatMap(e1 -> e1.stream()) .forEach(s -> System.out.println(s + " "));

D. Stream.of(list1, list2) .flatMapToInt(list -> list.stream()) .forEach(s -> System.out.print(s + " "));

Buy Now
Questions 10

Given the code fragments:

and

What is the result?

A. France Optional[NotFound]

B. Optional [France] Optional [NotFound]

C. Optional[France] Not Found

D. France Not Found

Buy Now
Questions 11

Given:

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

A. T

B. R C. P

D. S

E. Q

F. U

Buy Now
Questions 12

Given:

Which option fails?

A. Foo mark = new Foo ("Steve", 100);

B. Foo pair = Foo.twice ("Hello World!");

C. Foo percentage = new Foo("Steve", 100);

D. Foo grade = new Foo <> ("John", "A");

Buy Now
Questions 13

Given the definition of the Emp class:

public class Emp

private String eName;

private Integer eAge;

Emp(String eN, Integer eA) {

this.eName = eN;

this.eAge = eA;

}

public Integer getEAge () {return eAge;}

public String getEName () {return eName;}

}

and code fragment:

Listli = Arrays.asList(new Emp("Sam", 20), New Emp("John", 60), New Emp("Jim", 51));

Predicate agVal = s -> s.getEAge() <= 60; //line n1

li = li.stream().filter(agVal).collect(Collectors.toList());

Stream names = li.stream()map.(Emp::getEName); //line n2

names.forEach(n -> System.out.print(n + " "));

What is the result?

A. Sam John Jim

B. John Jim

C. A compilation error occurs at line n1.

D. A compilation error occurs at line n2.

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

PDF (Q&A)

$49.99

VCE

$55.99

PDF + VCE

$65.99