1z0-830: Java SE 21 Developer Professional System.out.println Practice Questions
The free 1z0-830: Java SE 21 Developer Professional questions that deal with system.out.println, with answers and explanations. The full bank and the timed practice test cover every topic the exam asks about.
Question #2
Given: java public class Versailles { int mirrorsCount; int gardensHectares; void Versailles() { // n1 this.mirrorsCount = 17; this.gardensHectares = 800; System.out.println("Hall of Mirrors has " + mirrorsCount + " mirrors."); System.out.println("The gardens cover " + gardensHectares + " hectares."); } public static void main(String[] args) { var castle = new Versailles(); // n2 } } What is printed?
Correct answer: C
Explanation
Because it declares a return type, void Versailles() is a method rather than a constructor, so the implicit default constructor runs and no print statement executes. The program compiles and exits without output.
Question #5
Given: java Runnable task1 = () -> System.out.println("Executing Task-1"); Callable<String> task2 = () -> { System.out.println("Executing Task-2"); return "Task-2 Finish."; }; ExecutorService execService = Executors.newCachedThreadPool(); // INSERT CODE HERE execService.awaitTermination(3, TimeUnit.SECONDS); execService.shutdownNow(); Which of the following statements, inserted in the code above, printsboth: "Executing Task-2" and "Executing Task-1"?
Select 2 answers.
Correct answer: G, H
Explanation
submit is overloaded for both Runnable and Callable, so submit(task1) and submit(task2) both schedule their task and print its message. execute accepts only Runnable, and call/run are not ExecutorService methods.
Continue with 1z0-830: Java SE 21 Developer Professional
Unlock the full question bank
You have read the first 10 questions. A subscription opens every question in 1z0-830: Java SE 21 Developer Professional, the full timed practice test, and your progress and weak-topic reporting.
Single exam
$19.99for 30 days
Full question bank and practice test for one exam, for 30 days.
Single exam
$49.99for 1 year
One exam for a full year. Nothing renews and nothing to cancel.
Full access
$39.99/mo
Every exam in the catalogue, month to month.
Full access
$199.99/yr
Every exam in the catalogue for a year.
Already subscribed? Sign in to pick up where you left off.
All 1z0-830: Java SE 21 Developer Professional practice questions →
