Oracle Java SE 21 Developer Professional 1z1-830 Prüfungsfragen mit Lösungen:
1. Which of the following statements are correct?
A) You can use 'private' access modifier with all kinds of classes
B) None
C) You can use 'final' modifier with all kinds of classes
D) You can use 'protected' access modifier with all kinds of classes
E) You can use 'public' access modifier with all kinds of classes
2. Given:
java
StringBuilder result = Stream.of("a", "b")
.collect(
() -> new StringBuilder("c"),
StringBuilder::append,
(a, b) -> b.append(a)
);
System.out.println(result);
What is the output of the given code fragment?
A) abc
B) cbca
C) cba
D) bac
E) cacb
F) bca
G) acb
3. Given:
java
var ceo = new HashMap<>();
ceo.put("Sundar Pichai", "Google");
ceo.put("Tim Cook", "Apple");
ceo.put("Mark Zuckerberg", "Meta");
ceo.put("Andy Jassy", "Amazon");
Does the code compile?
A) False
B) True
4. Given:
java
public class Test {
public static void main(String[] args) throws IOException {
Path p1 = Path.of("f1.txt");
Path p2 = Path.of("f2.txt");
Files.move(p1, p2);
Files.delete(p1);
}
}
In which case does the given program throw an exception?
A) File f1.txt exists while file f2.txt doesn't
B) Both files f1.txt and f2.txt exist
C) Neither files f1.txt nor f2.txt exist
D) An exception is always thrown
E) File f2.txt exists while file f1.txt doesn't
5. Given:
java
String colors = "red\n" +
"green\n" +
"blue\n";
Which text block can replace the above code?
A) None of the propositions
B) java
String colors = """
red \s
green\s
blue \s
""";
C) java
String colors = """
red \t
green\t
blue \t
""";
D) java
String colors = """
red
green
blue
""";
E) java
String colors = """
red \
green\
blue \
""";
Fragen und Antworten:
1. Frage Antwort: B | 2. Frage Antwort: C | 3. Frage Antwort: A | 4. Frage Antwort: D | 5. Frage Antwort: D |