Question 41 · 52 in bank
Given the course table:
Given the code fragment:

What is the result?
Show answer
Answer: A
Java SE 17 Developer52 questions across 6 pages are complete and free, with no account or card.
52 questions in this bank
Free access · progress saved on this device
Given the course table:
Given the code fragment:

What is the result?
Answer: A
Given the code fragment:
What is the result?
Answer: B
package q05; import java.time.Duration; import java.time.Period; public class Q05 { public static void main(String[] args) { Duration duration = Duration.ofMillis(5000); System.out.print(duration); duration = Duration.ofSeconds(60); System.out.print(duration); Period period = Period.ofDays(6); System.out.print(period); } } // Result: // PT5SPT1MP6D
Source: Adapted from community discussion — james2033
Given the code fragment:
What is the result?
Answer: B
package q50; public class Q50 { public static void main(String[] args) { Pet p = new Pet("Dog"); Pet p1 = p; p1.name = "Cat"; p = p1; System.out.println(p.name); p = null; System.out.println(p1.name); } } class Pet { public static String name; public Pet(String name) { this.name = name; } public String name() { return name; } public void setName(String name) { this.name = name; } } // Result: // Cat // Cat
Source: Adapted from community discussion — james2033
Given the code fragment:
Which action enables the code to compile?
Answer: E
package q06; record Product(int pNumber, String pName) { // int regNo = 100; static int regNo = 100; public int getRegNumber() { return regNo; } } public class App { public static void main(String[] args) { Product p1 = new Product(1111, "Ink Bottle"); } }
Source: Adapted from community discussion — james2033
Given:

What is the result?
Answer: C
package q07; public class Weather { public enum Forecast { SUNNY, CLOUDY, RAINY; @Override public String toString() { return "SNOWY"; } } public static void main(String[] args) { System.out.print(Forecast.SUNNY.ordinal() + " "); System.out.print(Forecast.valueOf("cloudy".toUpperCase())); } } // Result: // 0 SNOWY
Source: Adapted from community discussion — james2033
Given the code fragment:

What is the result?
Answer: B
package q08; import java.util.List; public class Q08 { public static void main(String[] args) { List specialDays = List.of("NewYear", "Valentines", "Spring", "Labour"); System.out.print(specialDays.stream().allMatch(s -> s.equals("Labour"))); System.out.print(" " + specialDays.stream().anyMatch(s -> s.equals("Labour"))); System.out.print(" " + specialDays.stream().noneMatch(s -> s.equals("Halloween"))); System.out.print(" " + specialDays.stream().findFirst()); } } // Result: // false true true Optional[NewYear]
Source: Adapted from community discussion — james2033
Given:
Which statement is true while the program prints GC?
Answer: D
Given the code fragment:
Which code fragment prints the elements of sList?
Answer: A
Given:

What is the result?
Answer: B
Given the code fragments: record Product(String name, double price) {} and,
What is the result?
Answer: D
Keyboard:J Kmove between questionsA–Dselect an answerRshow or hide the answer← →change page
1Z0-829 practice, question 41. 52 questions available.
Version 1.0.0. How we source questions