What is the output of the following snippet? (Assume the file exists)
java
Path path = Paths.get("C:\\home\\joe\\foo");
System.out.println(path.getName(0));
Given:
java
System.out.print(Boolean.logicalAnd(1 == 1, 2 < 1));
System.out.print(Boolean.logicalOr(1 == 1, 2 < 1));
System.out.print(Boolean.logicalXor(1 == 1, 2 < 1));
What is printed?
Given a properties file on the classpath named Person.properties with the content:
ini
name=James
And:
java
public class Person extends ListResourceBundle {
protected Object[][] getContents() {
return new Object[][]{
{"name", "Jeanne"}
};
}
}
And:
java
public class Test {
public static void main(String[] args) {
ResourceBundle bundle = ResourceBundle.getBundle("Person");
String name = bundle.getString("name");
System.out.println(name);
}
}
What is the given program's output?
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?
How would you create a ConcurrentHashMap configured to allow a maximum of 10 concurrent writer threads and an initial capacity of 42?
Which of the following options meets this requirement?
Given:
java
public class ExceptionPropagation {
public static void main(String[] args) {
try {
thrower();
System.out.print("Dom Pérignon, ");
} catch (Exception e) {
System.out.print("Chablis, ");
} finally {
System.out.print("Saint-Émilion");
}
}
static int thrower() {
try {
int i = 0;
return i / i;
} catch (NumberFormatException e) {
System.out.print("Rosé");
return -1;
} finally {
System.out.print("Beaujolais Nouveau, ");
}
}
}
What is printed?