Study HIGH Quality 1z1-809 Free Study Guides and Exams Tutorials [Q33-Q52]

Share

Study HIGH Quality 1z1-809  Free Study Guides and Exams Tutorials

Download Oracle 1z1-809 Exam Dumps to Pass Exam Easily

NEW QUESTION # 33
Given the code fragment:
ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 3, 0, 0, 0,
ZoneID.of("UTC-7"));
ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0,
ZoneID.of("UTC-5"));
long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1
System.out.println("Travel time is" + hrs + "hours");
What is the result?

  • A. Travel time is 8 hours
  • B. An exception is thrown at line n1.
  • C. Travel time is 4 hours
  • D. Travel time is 6 hours

Answer: C


NEW QUESTION # 34
Given the code fragment:

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

  • A. 0
  • B. An exception is thrown at run time.
  • C. 1
  • D. 2

Answer: C


NEW QUESTION # 35
In 2015, daylight saving time in New York, USA, begins on March 8th at 2:00 AM. As a result, 2:00 AM
becomes 3:00 AM.
Given the code fragment:

Which is the result?

  • A. 2:00 - difference: 1
  • B. 3:00 - difference: 2
  • C. 4:00 - difference: 2
  • D. 4:00 - difference: 3

Answer: C


NEW QUESTION # 36
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 (Supplier<Bird> bird) {
    bird.get( ) fly ();
    }
  • B. static void fly (Supplier<? extends Bird> bird) {
    LOST
  • C. static void fly (Consumer<Bird> bird) {
    bird :: fly (); }
  • D. static void fly (Consumer<? extends Bird> bird) {
    bird.accept( ) fly ();
    }

Answer: A

Explanation:
NOTE: Very confusing question. There is no logic in the options.


NEW QUESTION # 37
Given:

Your design requires that:
fuelLevel of Engine must be greater than zero when the start()method is invoked.

The code must terminate if fuelLevelof Engineis less than or equal to zero.

Which code fragment should be added at line n1to express this invariant condition?

  • A. assert (fuelLevel) : "Terminating...";
  • B. assert fuelLevel > 0: "Impossible fuel" ;
  • C. assert (fuelLevel > 0) : System.out.println ("Impossible fuel");
  • D. assert fuelLevel < 0: System.exit(0);

Answer: D


NEW QUESTION # 38
Given:

What is the result?

  • A. An exception is thrown at runtime.
  • B. Compilation fails.
  • C. 0 0 30 40
  • D. 10 20 30 40

Answer: C


NEW QUESTION # 39
Given the code fragment:
public static void main (String[] args) throws IOException {
BufferedReader brCopy = null;
try (BufferedReader br = new BufferedReader (new FileReader("employee.txt"))) { //
line n1
br.lines().forEach(c -> System.out.println(c));
brCopy = br;//line n2
}
brCopy.ready(); //line n3;
}
Assume that the ready method of the BufferedReader, when called on a closed BufferedReader, throws an exception, and employee.txt is accessible and contains valid text.
What is the result?

  • A. A compilation error occurs at line n2.
  • B. The code prints the content of the employee.txt file and throws an exception at line n3.
  • C. A compilation error occurs at line n1.
  • D. A compilation error occurs at line n3.

Answer: C


NEW QUESTION # 40
Given:

and this code fragment:

What is the result?

  • A. Open-Close-Open-Close-
  • B. Open-Close-Exception - 1Open-Close-
  • C. A compilation error occurs at line n1.
  • D. Open-Close-Open-

Answer: C


NEW QUESTION # 41
Given:
public class Test<T> {
private T t;
public T get () {
return t;
}
public void set (T t) {
this.t = t;
}
public static void main (String args [ ] ) {
Test<String> type = new Test<>();
Test type 1 = new Test ();//line n1
type.set("Java");
type1.set(100);//line n2
System.out.print(type.get() + " " + type1.get());
}
}
What is the result?

  • A. A compilation error occurs. To rectify it, replace line n1 with:
    Test<Integer> type1 = new Test<>();
  • B. java.lang.string@<hashcode>java.lang.Integer@<hashcode>
  • C. Java 100
  • D. A compilation error occurs. To rectify it, replace line n2 with:
    type1.set (Integer(100));

Answer: C


NEW QUESTION # 42
Given:

and the code fragment:

What is the result?

  • A. A compilation error occurs at line n1.
  • B. An Exceptionis thrown at run time.
  • C. 0
  • D. 1

Answer: A


NEW QUESTION # 43
Given the code fragment:

What is the result?

  • A. No Match
  • B. Match 1
  • C. A nullPointerException is thrown at runtime.
  • D. Match 2

Answer: D


NEW QUESTION # 44
Given the code fragment:

Assume that dbURL, userName, and passwordare valid.
Which code fragment can be inserted at line n1to enable the code to print Connection Established?
Properties prop = new Properties();

  • A. prop.put ("user", userName);
    prop.put ("password", password);
    con = DriverManager.getConnection (dbURL, prop);
    con = DriverManager.getConnection (userName, password, dbURL);
  • B. Properties prop = new Properties();
  • C. con.setClientInfo ("user", userName);
    con.setClientInfo ("password", password);
  • D. prop.put ("userid", userName);
    prop.put ("password", password);
    prop.put("url", dbURL);
    con = DriverManager.getConnection (prop);
    con = DriverManager.getConnection (dbURL);

Answer: A


NEW QUESTION # 45
Given the code fragment:
ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 3, 0, 0, 0, ZoneID.of("UTC-7")); ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of("UTC-5")); long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1 System.out.println("Travel time is" + hrs + "hours"); What is the result?

  • A. Travel time is 4 hours
  • B. Travel time is 8 hours
  • C. An exception is thrown at line n1.
  • D. Travel time is 6 hours

Answer: C


NEW QUESTION # 46
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 = null;
Optional<Address> addrs1 = Optional.ofNullable (address);
Employee e1 = new Employee (addrs1);
String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : "City Not
available";
What is the result?

  • A. City Not available
  • B. New York
  • C. null
  • D. A NoSuchElementException is thrown at run time.

Answer: C


NEW QUESTION # 47
You want to create a singleton class by using the Singleton design pattern.
Which two statements enforce the singleton nature of the design?

  • A. Override equals() and hashCode() methods of the java.lang.Object class.
  • B. Make the class static.
  • C. Make the constructor private.
  • D. Use a static reference to point to the single instance.
  • E. Implement the Serializable interface.

Answer: C,D


NEW QUESTION # 48
Given the code fragment:
List<String> empDetails = Arrays.asList("100, Robin, HR",
"200, Mary, AdminServices",
"101, Peter, HR");
empDetails.stream()
.filter(s-> s.contains("1"))
.sorted()
.forEach(System.out::println); //line n1
What is the result?

  • A. A compilation error occurs at line n1.
  • B. 100, Robin, HR101, Peter, HR200, Mary, AdminServices
  • C. 100, Robin, HR101, Peter, HR
  • D. 100, Robin, HR200, Mary, AdminServices101, Peter, HR

Answer: C


NEW QUESTION # 49
Given the code fragment:
Map<Integer, String> books = new TreeMap<>();
books.put (1007, "A");
books.put (1002, "C");
books.put (1001, "B");
books.put (1003, "B");
System.out.println (books);
What is the result?

  • A. {1007 = A, 1002 = C, 1001 = B, 1003 = B}
  • B. {1001 = B, 1002 = C, 1003 = B, 1007 = A}
  • C. {1007 = A, 1001 = B, 1003 = B, 1002 = C}
  • D. {1002 = C, 1003 = B, 1007 = A}

Answer: B

Explanation:
Explanation/Reference:
Reference: TreeMap inherits SortedMap and automatically sorts the element's key


NEW QUESTION # 50
Which two statements are true about localizing an application? (Choose two.)

  • A. Support for new regional languages does not require recompilation of the code.
  • B. Textual elements (messages and GUI labels) are hard-coded in the code.
  • C. Language codes use lowercase letters and region codes use uppercase letters.
  • D. Language and region-specific programs are created using localized data.
  • E. Resource bundle files include data and currency information.

Answer: A,C

Explanation:
References:


NEW QUESTION # 51
Given the content:

and given the code fragment:

Which two code fragments, when inserted at line 1independently, enable the code to print
"Wie geht's?"

  • A. currentLocale = new Locale.Builder ().setLanguage ("de").setRegion ("DE").build();
  • B. currentLocale = new Locale ("de", "DE");
  • C. currentLocale = Locale.GERMAN;
  • D. currentlocale = new Locale();
    currentLocale.setLanguage ("de");
    currentLocale.setRegion ("DE");
  • E. currentLocale = Locale.getInstance(Locale.GERMAN,Locale.GERMANY);

Answer: A


NEW QUESTION # 52
......


Oracle 1z1-809: Java SE 8 Programmer II exam is a challenging certification exam that tests the skills and knowledge of experienced Java programmers. Becoming certified in Java SE 8 can open up new career opportunities and demonstrate to employers that you have the skills and knowledge needed to excel in the field of IT.

 

Get 100% Real Free Java SE 1z1-809 Sample Questions: https://examcollection.actualcollection.com/1z1-809-exam-questions.html