Exam2pass
0 items Sign In or Register
  • Home
  • IT Exams
  • Guarantee
  • FAQs
  • Reviews
  • Contact Us
  • Demo
Exam2pass > Oracle > Oracle Certifications > 1Z0-816 > 1Z0-816 Online Practice Questions and Answers

1Z0-816 Online Practice Questions and Answers

Questions 4

Which code fragment does a service use to load the service provider with a Print interface?

A. private Print print = com.service.Provider.getInstance();

B. private java.util.ServiceLoader loader = ServiceLoader.load(Print.class);

C. private java.util.ServiceLoader loader = new java.util.ServiceLoader<>();

D. private Print print = new com.service.Provider.PrintImpl();

Buy Now

Correct Answer: B

Reference: https://docs.oracle.com/javase/8/docs/api/?java/util/ServiceLoader.html

Questions 5

Given:

What is required to make the Foo class thread safe?

A. No change is required.

B. Make the declaration of lock static.

C. Replace the lock constructor call with new ReentrantLock (true).

D. Move the declaration of lock inside the foo method.

Buy Now

Correct Answer: C

Reference: https://stackoverflow.com/questions/55134811/how-to-make-java-class-thread-safe

Questions 6

Given:

Which is true?

A. System.out is the standard output stream. The stream is open only when System.out is called.

B. System.in cannot reassign the other stream.

C. System.out is an instance of java.io.OutputStream by default.

D. System.in is the standard input stream. The stream is already open.

Buy Now

Correct Answer: D

Reference: https://www.geeksforgeeks.org/java-lang-system-class-java/

Questions 7

Given:

You want to use the myResource class in a try-with-resources statement. Which change will accomplish this?

A. Extend AutoCloseable and override the close method.

B. Implement AutoCloseable and override the autoClose method.

C. Extend AutoCloseable and override the autoClose method.

D. Implement AutoCloseable and override the close method.

Buy Now

Correct Answer: D

Reference: https://stackabuse.com/the-try-with-resources-statement-in-java/

Questions 8

Given:

And the command: java Main Helloworld What is the result ?

A. Input: Echo:

B. Input: Helloworld Echo: Helloworld

C. Input: Then block until any input comes from System.in.

D. Input: Echo: Helloworld

E. A NullPointerException is thrown at run time.

Buy Now

Correct Answer: C

Questions 9

Given:

public class X { }

and public final class Y extends X { }

What is the result of compiling these two classes?

A. The compilation fails because there is no zero args constructor defined in class X.

B. The compilation fails because either class X or class Y needs to implement the toString() method.

C. The compilation fails because a final class cannot extend another class.

D. The compilation succeeds.

Buy Now

Correct Answer: B

Questions 10

Which code is correct?

A. Runnable r = "Message" -> System.out.println();

B. Runnable r = () -> System.out::print;

C. Runnable r = () -> {System.out.println("Message");};

D. Runnable r = -> System.out.println("Message");

E. Runnable r = {System.out.println("Message")};

Buy Now

Correct Answer: C

Reference: https://www.oracle.com/technical-resources/articles/java/architect-lambdas-part1.html

Questions 11

Which three guidelines are used to protect confidential information? (Choose three.)

A. Limit access to objects holding confidential information.

B. Clearly identify and label confidential information.

C. Manage confidential and other information uniformly.

D. Transparently handle information to improve diagnostics.

E. Treat user input as normal information.

F. Validate input before storing confidential information.

G. Encapsulate confidential information.

Buy Now

Correct Answer: ADF

Reference: https://danielkvist.net/code/java-secure-coding-guidelines

Questions 12

Given the code fragment:

var pool = Executors.newFixedThreadPool(5);

Future outcome = pool.submit(() -> 1);

Which type of lambda expression is passed into submit()?

A. java.lang.Runnable

B. java.util.function.Predicate

C. java.util.function.Function

D. java.util.concurrent.Callable

Buy Now

Correct Answer: D

Reference: https://www.codota.com/code/java/methods/java.util.concurrent.Executors/ newFixedThreadPool

Questions 13

Given:

LocalDate d1 = LocalDate.of(1997,2,7); DateTimeFormatter dtf = DateTimeFormatter.ofPattern( /*insert code here*/ ); System.out.println(dtf.format (d1)); Which pattern formats the date as Friday 7th of February 1997?

A. "eeee dd+"th of"+ MMM yyyy"

B. "eeee dd'th of' MMM yyyy"

C. "eeee d+"th of"+ MMMM yyyy"

D. "eeee d'th of' MMMM yyyy"

Buy Now

Correct Answer: B

Reference: https://books.google.com.pk/books?id=PmiO65T9hF0Candpg=PA385andlpg=PA385anddq=java +pattern+formats+eeee+d%2Bth+of%2B+MMMM+yyyyandsource=blandots=IJN_-AnWQjandsig=ACfU3U2RJf7iuK3t_SKARwLSaak9xxV09Aandhl=enandsa=Xandved=2ahUKEwi4m6LL3vLoAhVgT RUIHURpC38Q6AEwDHoECBQQAQ#v=onepageandq=java%20pattern%20formats%20eeee%20d%2Bth% 20of%2B%20MMMM% 20yyyyandf=false

Exam Code: 1Z0-816
Exam Name: Java SE 11 Programmer II
Last Update: Jun 30, 2025
Questions: 80

PDF (Q&A)

$45.99
ADD TO CART

VCE

$49.99
ADD TO CART

PDF + VCE

$59.99
ADD TO CART

Exam2Pass----The Most Reliable Exam Preparation Assistance

There are tens of thousands of certification exam dumps provided on the internet. And how to choose the most reliable one among them is the first problem one certification candidate should face. Exam2Pass provide a shot cut to pass the exam and get the certification. If you need help on any questions or any Exam2Pass exam PDF and VCE simulators, customer support team is ready to help at any time when required.

Home | Guarantee & Policy |  Privacy & Policy |  Terms & Conditions |  How to buy |  FAQs |  About Us |  Contact Us |  Demo |  Reviews

2025 Copyright @ exam2pass.com All trademarks are the property of their respective vendors. We are not associated with any of them.