Oracle Java SE 21 Developer Professional - 1z1-830 FREE EXAM DUMPS QUESTIONS & ANSWERS

Given:
java
public class OuterClass {
String outerField = "Outer field";
class InnerClass {
void accessMembers() {
System.out.println(outerField);
}
}
public static void main(String[] args) {
System.out.println("Inner class:");
System.out.println("------------");
OuterClass outerObject = new OuterClass();
InnerClass innerObject = new InnerClass(); // n1
innerObject.accessMembers(); // n2
}
}
What is printed?
Correct Answer: A Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Given:
java
var deque = new ArrayDeque<>();
deque.add(1);
deque.add(2);
deque.add(3);
deque.add(4);
deque.add(5);
System.out.print(deque.peek() + " ");
System.out.print(deque.poll() + " ");
System.out.print(deque.pop() + " ");
System.out.print(deque.element() + " ");
What is printed?
Correct Answer: A Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Consider the following methods to load an implementation of MyService using ServiceLoader. Which of the methods are correct? (Choose all that apply)
Correct Answer: C,D Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Given:
java
interface A {
default void ma() {
}
}
interface B extends A {
static void mb() {
}
}
interface C extends B {
void ma();
void mc();
}
interface D extends C {
void md();
}
interface E extends D {
default void ma() {
}
default void mb() {
}
default void mc() {
}
}
Which interface can be the target of a lambda expression?
Correct Answer: A Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Given:
java
String s = " ";
System.out.print("[" + s.strip());
s = " hello ";
System.out.print("," + s.strip());
s = "h i ";
System.out.print("," + s.strip() + "]");
What is printed?
Correct Answer: D Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Which of the following can be the body of a lambda expression?
Correct Answer: D Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
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?
Correct Answer: B Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Given:
java
public class SpecialAddition extends Addition implements Special {
public static void main(String[] args) {
System.out.println(new SpecialAddition().add());
}
int add() {
return --foo + bar--;
}
}
class Addition {
int foo = 1;
}
interface Special {
int bar = 1;
}
What is printed?
Correct Answer: A Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
Given:
java
public class BoomBoom implements AutoCloseable {
public static void main(String[] args) {
try (BoomBoom boomBoom = new BoomBoom()) {
System.out.print("bim ");
throw new Exception();
} catch (Exception e) {
System.out.print("boom ");
}
}
@Override
public void close() throws Exception {
System.out.print("bam ");
throw new RuntimeException();
}
}
What is printed?
Correct Answer: E Vote an answer
Explanation: Only visible for FreeCram members. You can sign-up / login (it's free).
0
0
0
10