최신 1z1-830 무료덤프 - Oracle Java SE 21 Developer Professional
Given:
java
package com.vv;
import java.time.LocalDate;
public class FetchService {
public static void main(String[] args) throws Exception {
FetchService service = new FetchService();
String ack = service.fetch();
LocalDate date = service.fetch();
System.out.println(ack + " the " + date.toString());
}
public String fetch() {
return "ok";
}
public LocalDate fetch() {
return LocalDate.now();
}
}
What will be the output?
java
package com.vv;
import java.time.LocalDate;
public class FetchService {
public static void main(String[] args) throws Exception {
FetchService service = new FetchService();
String ack = service.fetch();
LocalDate date = service.fetch();
System.out.println(ack + " the " + date.toString());
}
public String fetch() {
return "ok";
}
public LocalDate fetch() {
return LocalDate.now();
}
}
What will be the output?
정답: C
설명: (DumpTOP 회원만 볼 수 있음)
What do the following print?
java
public class Main {
int instanceVar = staticVar;
static int staticVar = 666;
public static void main(String args[]) {
System.out.printf("%d %d", new Main().instanceVar, staticVar);
}
static {
staticVar = 42;
}
}
java
public class Main {
int instanceVar = staticVar;
static int staticVar = 666;
public static void main(String args[]) {
System.out.printf("%d %d", new Main().instanceVar, staticVar);
}
static {
staticVar = 42;
}
}
정답: D
설명: (DumpTOP 회원만 볼 수 있음)
Given:
java
void verifyNotNull(Object input) {
boolean enabled = false;
assert enabled = true;
assert enabled;
System.out.println(input.toString());
assert input != null;
}
When does the given method throw a NullPointerException?
java
void verifyNotNull(Object input) {
boolean enabled = false;
assert enabled = true;
assert enabled;
System.out.println(input.toString());
assert input != null;
}
When does the given method throw a NullPointerException?
정답: E
설명: (DumpTOP 회원만 볼 수 있음)
Given:
java
ExecutorService service = Executors.newFixedThreadPool(2);
Runnable task = () -> System.out.println("Task is complete");
service.submit(task);
service.shutdown();
service.submit(task);
What happens when executing the given code fragment?
java
ExecutorService service = Executors.newFixedThreadPool(2);
Runnable task = () -> System.out.println("Task is complete");
service.submit(task);
service.shutdown();
service.submit(task);
What happens when executing the given code fragment?
정답: B
설명: (DumpTOP 회원만 볼 수 있음)
Given:
java
sealed class Vehicle permits Car, Bike {
}
non-sealed class Car extends Vehicle {
}
final class Bike extends Vehicle {
}
public class SealedClassTest {
public static void main(String[] args) {
Class<?> vehicleClass = Vehicle.class;
Class<?> carClass = Car.class;
Class<?> bikeClass = Bike.class;
System.out.print("Is Vehicle sealed? " + vehicleClass.isSealed() +
"; Is Car sealed? " + carClass.isSealed() +
"; Is Bike sealed? " + bikeClass.isSealed());
}
}
What is printed?
java
sealed class Vehicle permits Car, Bike {
}
non-sealed class Car extends Vehicle {
}
final class Bike extends Vehicle {
}
public class SealedClassTest {
public static void main(String[] args) {
Class<?> vehicleClass = Vehicle.class;
Class<?> carClass = Car.class;
Class<?> bikeClass = Bike.class;
System.out.print("Is Vehicle sealed? " + vehicleClass.isSealed() +
"; Is Car sealed? " + carClass.isSealed() +
"; Is Bike sealed? " + bikeClass.isSealed());
}
}
What is printed?
정답: B
설명: (DumpTOP 회원만 볼 수 있음)
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?
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?
정답: C
설명: (DumpTOP 회원만 볼 수 있음)
Given:
java
Map<String, Integer> map = Map.of("b", 1, "a", 3, "c", 2);
TreeMap<String, Integer> treeMap = new TreeMap<>(map);
System.out.println(treeMap);
What is the output of the given code fragment?
java
Map<String, Integer> map = Map.of("b", 1, "a", 3, "c", 2);
TreeMap<String, Integer> treeMap = new TreeMap<>(map);
System.out.println(treeMap);
What is the output of the given code fragment?
정답: F
설명: (DumpTOP 회원만 볼 수 있음)
Given:
java
try (FileOutputStream fos = new FileOutputStream("t.tmp");
ObjectOutputStream oos = new ObjectOutputStream(fos)) {
fos.write("Today");
fos.writeObject("Today");
oos.write("Today");
oos.writeObject("Today");
} catch (Exception ex) {
// handle exception
}
Which statement compiles?
java
try (FileOutputStream fos = new FileOutputStream("t.tmp");
ObjectOutputStream oos = new ObjectOutputStream(fos)) {
fos.write("Today");
fos.writeObject("Today");
oos.write("Today");
oos.writeObject("Today");
} catch (Exception ex) {
// handle exception
}
Which statement compiles?
정답: D
설명: (DumpTOP 회원만 볼 수 있음)