Go Back on 1z0-809 Exam
Available in 1, 3, 6 and 12 Months Free Updates Plans
PDF: $15 $60

Test Engine: $20 $80

PDF + Engine: $25 $99

1z0-809 Practice Test


Page 9 out of 26 Pages

Given the code fragment:
int b = 3;
if ( !(b > 3)) {
System.out.println("square ");
}{
System.out.println("circle ");
}
System.out.println("...");
What is the result?


A.

square...


B.

circle...


C.

squarecircle...


D.

Compilation fails.





C.
  

squarecircle...



Given the code fragment:


What is the result?


A.

20


B.

25


C.

29


D.

Compilation fails


E.

AnArrayIndexOutOfBoundsException is thrown at runtime





A.
  

20



Given:
public class Emp {
String fName;
String lName;
public Emp (String fn, String ln) {
fName = fn;
lName = ln;
}
public String getfName() { return fName; }
public String getlName() { return lName; }
}
and the code fragment:
List<Emp> emp = Arrays.asList (
new Emp (“John”, “Smith”),
new Emp (“Peter”, “Sam”),
new Emp (“Thomas”, “Wale”));
emp.stream()
//line n1
.collect(Collectors.toList());
Which code fragment, when inserted at line n1, sorts the employees list in descending
order of fName and then ascending order of lName?


A.

sorted
(Comparator.comparing(Emp::getfName).reserved().thenComparing(Emp::getlName))


B.

sorted (Comparator.comparing(Emp::getfName).thenComparing(Emp::getlName))


C.

map(Emp::getfName).sorted(Comparator.reserveOrder())


D.

map(Emp::getfName).sorted(Comparator.reserveOrder().map(Emp::getlName).reserved





A.
  

sorted
(Comparator.comparing(Emp::getfName).reserved().thenComparing(Emp::getlName))



Given the code fragments:
public class Book implements Comparator<Book> {
String name;
double price;
public Book () {}
public Book(String name, double price) {
this.name = name;
this.price = price;
}
public int compare(Book b1, Book b2) {
return b1.name.compareTo(b2.name);
}
public String toString() {
return name + “:” + price;
}
}
and
List<Book>books = Arrays.asList (new Book (“Beginning with Java”, 2), new book (“A
Guide to Java Tour”, 3));
Collections.sort(books, new Book());
System.out.print(books);
What is the result?


A.

[A Guide to Java Tour:3, Beginning with Java:2]


B.

[Beginning with Java:2, A Guide to Java Tour:3]


C.

A compilation error occurs because the Book class does not override the abstract
method compareTo().


D.

An Exception is thrown at run time.





A.
  

[A Guide to Java Tour:3, Beginning with Java:2]



Given the class definitions:

What is the result?


A.

Java
Java
Java


B.

Java
Jeve
va


C.

Java
Jeve
ve


D.

Compilation fails





D.
  

Compilation fails




Page 9 out of 26 Pages
Previous