[2021] 1z0-809 All-in-One Exam Guide Practice To your 1z0-809 Exam!
Preparations of 1z0-809 Exam 2021 Java SE Unlimited 195 Questions
NEW QUESTION 12
Given the code fragment:
Which code fragment, when inserted at line 7, enables printing 100?
- A. ToIntFunction<Integer> funRef = e -> e + 10;
int result = funRef.applyAsInt (value); - B. ToIntFunction funRef = e -> e + 10;
int result = funRef.apply (value); - C. IntFunction funRef = e -> e + 10;
Integer result = funRef.apply (10); - D. Function<Integer> funRef = e -> e + 10;
Integer result = funRef.apply(value);
Answer: D
NEW QUESTION 13
Given:
public enum USCurrency {
PENNY (1),
NICKLE(5),
DIME (10),
QUARTER(25);
private int value;
public USCurrency(int value) {
this.value = value;
}
public int getValue() {return value;}
}
public class Coin {
public static void main (String[] args) {
USCurrency usCoin =new USCurrency.DIME;
System.out.println(usCoin.getValue()):
}
}
Which two modifications enable the given code to compile?
- A. Add the final keyword in the declaration of value.
- B. Make the getter method of value as a static method.
- C. Remove the new keyword from the instantion of usCoin.
- D. Nest the USCurrency enumeration declaration within the Coin class.
- E. Make the USCurrency enumeration constructor private.
Answer: A,D
NEW QUESTION 14
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 false.
- B. The program prints true.
- C. A compilation error occurs. To ensure successful compilation, replace line n2 with:System.out.println
(b1.equals((Object) b2)); - D. A compilation error occurs. To ensure successful compilation, replace line n1 with:boolean equals
(Book obj) {
Answer: B
NEW QUESTION 15
Given the following segment of code:
Which two statements, If either were true, would make the code compile?
- A. MotorCycle is an interface that implements the Vehicle class.
- B. Vehicle and MotorCycle both implement the Transportation interface.
- C. Vehicle and MotorCycle both extend the Transportation superclass.
- D. motorCycle is a superclass of vehicle.
- E. Vehicle is an interface that is implemented by the Motorcycle class.
- F. Vehicle is a superclass of MotorCycle.
Answer: E,F
NEW QUESTION 16
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?
static void fly (Consumer<Bird> bird) {
- A. bird :: fly ();
}
static void fly (Consumer<? extends Bird> bird) { - B. LOST
- C. bird.accept( ) fly ();
}
static void fly (Supplier<Bird> bird) { - D. bird.get( ) fly ();
}
static void fly (Supplier<? extends Bird> bird) {
Answer: D
NEW QUESTION 17
Given the code fragment:
Which code fragment, when inserted at line n1, enables the code to print /First.txt?
- A. Path iP = new Paths ("/First.txt");
- B. Path iP = Paths.toPath ("/First.txt");
- C. Path iP = Paths.get ("/", "First.txt");
- D. Path iP = new Path ("/First.txt");
Answer: C
NEW QUESTION 18
Given the code fragments:
class Employee {
Optional<Address> address;
Employee (Optional<Address> address) {
this.address = address;
}
public Optional<Address> getAddress() { return address; }
}
class Address {
String city = "New York";
public String getCity { return city: }
public String toString() {
return city;
}
}
and
Address address = new Address;
Optional<Address> addrs1 = Optional.ofNullable (address);
Employee e1 = new Employee (addrs1);
String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : "City Not available"; System.out.println(eAddress); What is the result?
- A. New York
- B. null
- C. A NoSuchElementException is thrown at run time.
- D. City Not available
Answer: B
NEW QUESTION 19
Given:
Which option fails?
- A. Foo<String, String> grade = new Foo <> ("John", "A");
- B. Foo<Object, Object> percentage = new Foo<String, Integer>("Steve", 100);
- C. Foo<String, String> pair = Foo.<String>twice ("Hello World!");
- D. Foo<String, Integer> mark = new Foo<String, Integer> ("Steve", 100);
Answer: D
NEW QUESTION 20
Given the code fragment:
BiFunction<Integer, Double, Integer> val = (t1, t2) -> t1 + t2;//line
n1
System.out.println(val.apply(10, 10.5));
What is the result?
- A. 20.5
- B. A compilation error occurs at line n1.
- C. 0
- D. A compilation error occurs at line n2.
Answer: B
NEW QUESTION 21
Given:
And given the commands:
javac Test . java
java Test
What is the result?
- A. A NullPointerException is thrown at runtime.
- B. Compilation fails at line n1.
- C. Java EE
- D. java SE
Answer: A
NEW QUESTION 22
Given the code fragment:
List<Integer> list1 = Arrays.asList(10, 20);
List<Integer> list2 = Arrays.asList(15, 30);
//line n1
Which code fragment, when inserted at line n1, prints 10 20 15 30?
- A. list1.stream()
.flatMap(list2.stream().flatMap(e1 -> e1.stream()) .forEach(s -> System.out.println(s + " ")); - B. Stream.of(list1, list2)
.flatMap(list -> list.intStream())
.forEach(s -> System.out.print(s + " ")); - C. Stream.of(list1, list2)
.flatMapToInt(list -> list.stream())
.forEach(s -> System.out.print(s + " ")); - D. Stream.of(list1, list2)
.flatMap(list -> list.stream())
.forEach(s -> System.out.print(s + " "));
Answer: D
NEW QUESTION 23
Given the code fragment:
Path p1 = Paths.get("/Pics/MyPic.jpeg"); System.out.println (p1.getNameCount() + ":" + p1.getName(1) + ":" + p1.getFileName());
Assume that the Pics directory does NOT exist. What is the result?
- A. 2:MyPic.jpeg: MyPic.jpeg
- B. 2:Pics: MyPic.jpeg
- C. 1:Pics:/Pics/ MyPic.jpeg
- D. An exception is thrown at run time.
Answer: C
NEW QUESTION 24
Given the code fragment:
What is the result?
- A. Susan
Allen
[Susan, David] - B. Susan
Susan
[Susan, Allen] - C. David
David
[Susan, Allen] - D. David
Allen
[Susan] - E. Susan
Allen
[David]
Answer: E
NEW QUESTION 25
Given:
From what threading problem does the program suffer?
- A. race condition
- B. deadlock
- C. starvation
- D. livelock
Answer: B
NEW QUESTION 26
Given:
Which two interfaces can you use to create lambda expressions? (Choose two.)
- A. U
- B. Q
- C. S
- D. T
- E. P
- F. R
Answer: A,D
NEW QUESTION 27
Given the code fragment:
Which code fragment, when inserted at line 7, enables printing 100?
Function<Integer> funRef = e -> e + 10;
- A. Integer result = funRef.apply(value);
IntFunction funRef = e -> e + 10; - B. int result = funRef.applyAsInt (value);
ToIntFunction funRef = e -> e + 10; - C. int result = funRef.apply (value);
- D. Integer result = funRef.apply (10);
ToIntFunction<Integer> funRef = e -> e + 10;
Answer: A
NEW QUESTION 28
Which two statements are true for a two-dimensional array of primitive data type?
- A. The length of each dimension must be the same.
- B. All methods of the class object may be invoked on the two-dimensional array.
- C. At the declaration time, the number of elements of the array in each dimension must be specified.
- D. It cannot contain elements of different types.
Answer: B,D
NEW QUESTION 29
Given the content:
and the code fragment:
What is the result?
- A. A compilation error occurs.
- B. username = Entrez le nom d'utilisateur
password = Entrez le mot de passe - C. username = Enter User Name
password = Enter Password - D. The program prints nothing.
Answer: B
NEW QUESTION 30
Given the structure of the Student table:
Student (id INTEGER, name VARCHAR)
Given the records from the STUDENT table:
Given the code fragment:
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists.
What is the result?
- A. The program prints Status: false and two records are deleted from the Student table.
- B. The program prints Status: false but the records from the Student table are not deleted.
- C. The program prints Status: true and two records are deleted from the Student table.
- D. A SQLException is thrown at runtime.
Answer: A
NEW QUESTION 31
Given:
class Student {
String course, name, city;
public Student (String name, String course, String city) {
this.course = course; this.name = name; this.city = city;
}
public String toString() {
return course + ":" + name + ":" + city;
}
public String getCourse() {return course;}
public String getName() {return name;}
public String getCity() {return city;}
and the code fragment:
List<Student> stds = Arrays.asList(
new Student ("Jessy", "Java ME", "Chicago"),
new Student ("Helen", "Java EE", "Houston"),
new Student ("Mark", "Java ME", "Chicago"));
stds.stream()
.collect(Collectors.groupingBy(Student::getCourse))
.forEach(src, res) -> System.out.println(scr));
What is the result?
- A. Java ME
[Java EE: Helen:Houston] - B. [Java ME: Jessy:Chicago, Java ME: Mark:Chicago]
[Java ME: Jessy:Chicago, Java ME: Mark:Chicago] - C. A compilation error occurs.
Java EE - D. [Java EE: Helen:Houston]
Answer: A
NEW QUESTION 32
Given:
and this code fragment:
What is the result?
- A. Open-Close-Open-
- B. A compilation error occurs at line n1.
- C. Open-Close-
- D. Exception - 1
Open-Close-
Open-Close-Open-Close-
Answer: B
NEW QUESTION 33
Given the following code for a planet object:
And the following main method:
What is the output?
- A. Option A
- B. Option D
- C. Option B
- D. Option C
- E. Option E
Answer: B
NEW QUESTION 34
Given the code fragment:
What is the result?
- A. An IndexOutOfBoundsException is thrown at runtime.
- B. (green, red, cyan, yellow)
- C. [green, red, yellow, cyan]
- D. [green, blue, yellow, cyan]
Answer: C
NEW QUESTION 35
Given:
What is the result?
- A. Marrown
String out of limits - B. Marrown
String out of limits
Array out of limits - C. Marrown
NanRed
JesOran - D. Marrown
String out of limits
JesOran
Answer: D
NEW QUESTION 36
Given:
Book.java:
public class Book {
private String read(String bname) { return "Read" + bname }
}
EBook.java:
public class EBook extends Book {
public class String read (String url) { return "View" + url }
}
Test.java:
public class Test {
public static void main (String[] args) {
Book b1 = new Book();
b1.read("Java Programing");
Book b2 = new EBook();
b2.read("http://ebook.com/ebook");
}
}
What is the result?
- A. Read Java ProgrammingRead http:/ ebook.com/ebook
- B. Read Java ProgrammingView http:/ ebook.com/ebook
- C. The EBook.java file fails to compile.
- D. The Test.java file fails to compile.
Answer: D
NEW QUESTION 37
......
Focus on 1z0-809 All-in-One Exam Guide For Quick Preparation: https://www.testpdf.com/1z0-809-exam-braindumps.html
Practice To 1z0-809 - TestPDF Remarkable Practice On your Java SE 8 Programmer II Exam: https://drive.google.com/open?id=1_z-h4R5GceZZAjPwMThGuEsAOl7IuC64
