1Z0-829 Exam Questions
49 real 1Z0-829 exam questions with expert-verified answers and explanations. Page 1 of 1.
- Question #1
Given the code fragments: class Test { volatile int x = 1; AtomicInteger xObj = new AtomicInteger(1); } and public static void main(String[] args) { Test t = new Test(); Runnable r...
- Question #2
Which statement is true?
- Question #3
Given the code fragment: ExecutorService executorService = Executors.newSingleThreadExecutor(); Set<Callable<String>> workers = new HashSet<Callable<String>>(); workers.add(new Cal...
- Question #4
Given the code fragment: String a = "Hello! Java"; System.out.print(a.indexOf("Java")); a.replace("Hello!", "Welcome!"); System.out.print(a.indexOf("Java")); StringBuilder b = new...
- Question #5
Given the code fragment: String myStr = "Hello Java 17"; String myTextBlk1 = """ Hello Java 17"""; String myTextBlk2 = """ Hello Java 17 """; System.out.print(myStr.equals(myTextBl...
- Question #6
Which two statements at Line n1 independently enable you to print 1250?
- Question #7
Given the code fragment: int a = 2; int b = ~a; int c = a^b; boolean d = a < b & a > c++; boolean e = a > b && a > c++; System.out.println(d + " " + c); System.out.println(e + " "...
- Question #7
What is the result?
- Question #8
Given: public class Test { public static void main(String[] args) { final int x = 2; int y = x; while (y<3) { switch (y) { case 0+x: y++; case 1: y++; } } System.out.println(y); }...
- Question #9
Given the code fragment: Integer rank = 4; switch (rank) { case 1,4 -> System.out.println("Range1"); case 5,8 -> System.out.println("Range2"); case 9,10 -> System.out.println("Rang...
- Question #10
Given the code fragment: List<String> specialDays = List.of("NewYear", "Valentines","Spring","Labour"); System.out.println(specialDays.stream().allMatch(s -> s.equals("Labour")));...
- Question #11
Given: class Product { String name; double price; Product(String s, double d) { this.name = s; this.price = d; } } class ElectricProduct extends Product { ElectricProduct(String na...
- Question #12
Given the code fragment: class Book { String author; String title; Book(String authorname, String title) { this.author = authorname; this.title = title; } } class SortBook { public...
- Question #13
Given the code fragment: List lst = new ArrayList<>(); lst.add("e1"); lst.add("e3"); lst.add("e2"); int x1 = Collections.binarySearch(lst, "e3"); System.out.println(x1); Collection...
- Question #14
Given: class A { public void mA() {System.out.println("mA");}} class B extends A {public void mB() {System.out.println("mB");}} class C extends B {public void mC() {System.out.prin...
- Question #15
Given the directory structure: module1: p1\ Doc.java p2\ Util.java Given the definition of the Doc class: package p1; public sealed class Doc permits WordDoc { } Which two are vali...
- Question #16
public enum Desig { CEO('A'), CMO('B'), CTO('C'), CFO('D'); char c; private Desig(char c) { this.c = c; } } and the code fragment: Arrays.stream(Desig.values()).dropWhile(s -> s.eq...
- Question #17
public class Weather { public enum Forecast { SUNNY, CLOUDY, RAINY; } @Override public String toString() { return "SNOWY";} public static void main(String[] args) { System.out.prin...
- Question #18
Given the product class: import java.io.*; public class Product implements Serializable { private static float averagePrice = 2.99f; private String description; private transient f...
- Question #19
Given: import java.io.Serializable; public class Software implements Serializable { private String title; public Software(String title) { this.title = title; } System.out.print("So...
- Question #20
Given the code fragments: class Car implements Serializable { private static long serialVersionUID = 454l; String name; public Car(String name) { this.name = name; } public String...
- Question #21
Assuming that the data, txt file exists and has the following content: Text1 Text2 Text3 Given the code fragment: try { Path p = new File("data.txt").toPath(); String lines = Files...
- Question #22
Given: public class Test { static interface Animal { } static class Dog implements Animal { } private static void play(Animal a) { System.out.print("flips"); } private static void...
- Question #23
Given: public class Test { public void sum(int a, int b) { System.out.print("A"); } public void sum(int a, float b) { System.out.print("B"); } public void sum(float a, float b) { S...
- Question #24
Given: public class Main { void print(int i) { System.out.println("hello"); } void print(long j) { System.out.println("there"); } public static void main(String[] args) { new Main(...
- Question #24
1. class Item { 2. String name; 3. public static void display() { 4. name = "Vase"; 5. System.out.println(name); 6. } 7. public void display(String design) { 8. this.name += name;...
- Question #25
Given the code fragment: Stream<String> s1 = Stream.of("A", "B", "C", "B"); Stream<String> s2 = Stream.of("A", "D", "E", "B"); Stream.concat(s1, s2).parallel().distinct().forEach(e...
- Question #26
Given: public class Test { public String attach1(List<String> data) { return data.parallelStream().reduce("w", (n,m) -> n+m, String::concat); } public String attach2(List<String> d...
- Question #27
Given: public class Test { public static void main(String[] args) { List<String> elements = Arrays.asList("car", "truck", "car", "bicycle", "car", "truck", "motorcycle"); Map<Strin...
- Question #28
record Product(int pNumber, String pName) { int regNo = 100; public int getRegNumber() { return regNo; } } public class App { public static void main(String[] args) { Product p1 =...
- Question #30
Given the course table: COURSE_ID COURSE_NAME COURSE_FEE COURSE_LEVEL 1021 Java Programmer 400.00 1 1022 Java Architect 600.00 2 1023 Java Master 800.00 3 Given the code fragment:...
- Question #31
Given the code fragment: List<Integer> listOfNumbers = List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); Which code fragment returns different values?
- Question #31
Which code line n1, obtains the java.io.Console object?
- Question #32
Given the code fragment: Duration duration = Duration.ofMillis(5000); System.out.println(duration); duration = Duration.ofSeconds(60); System.out.println(duration); Period period =...
- Question #33
Daylight Saving Time (DST) is the practice of advancing clocks at the start of spring by one hour and adjusting them backward by one hour in autumn. Considering that in 2021, DST i...
- Question #34
Given the code fragment: // login time:2021-01-12T21:58:18.817Z Instant loginTime = Instant.now(); Thread.sleep(1000); // logout time:2021-01-12T21:58:19.880Z Instant logoutTime =...
- Question #34
Given: public class App { public int x = 100; public static void main(String[] args) { int x = 1000; App t = new App(); t.myMethod(x); System.out.println(x); } public void myMethod...
- Question #35
Given the code fragment: abstract sealed interface Sint permits Story, Art { default String getTitle() { return "Book Title"; } } Which set of class definitions compiles?
- Question #36
Given: interface IFace { public void m1(); public default void m2() { System.out.println("m2"); } public static void m3() { System.out.println("m3"); } private void m4() { System.o...
- Question #36
Assume you have an automatic module from the module path display-ascii-0.2. jar. Which name is given to the automatic module based on the given JAR file?
- Question #37
Which statement is true about migration?
- Question #38
Given the content of the in. tart file: 23456789 and the code fragment: char[] buffer = new char[8]; int count = 0; try (FileReader in = new FileReader("in.txt"); FileWriter out =...
- Question #39
Which two code fragments compile?
- Question #40
Which statement is true about modules?
- Question #41
Given: Captions.properties file: user = UserName Captions_en.properties file: user = User name (EN) Captions_US.properties file: message = User name (US) Captions_en_US.properties...
- Question #44
Given: public class App{ String name; public App(String name){ this.name = name; } public static void main(String args[]) { App t1 = new App("t1"); App t2 = new App("t2"); t1 = t2;...
- Question #45
Given the code fragment: 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); What is the result?
- Question #46
Given: ```java public class StockException extends Exception { public StockException(String s) { super(s); } } public class OutofStockException extends StockException { public Outo...
- Question #48
Given: ```java package com.transport.vehicle.cars; public interface Car { int getSpeed(); } ``` and ```java package com.transport.vehicle.cars.impl; import com.transport.vehicle.ca...