Given:
import java.io.File;
import java.nio.file.Path;
public class Test12 {
static String displayDetails(String path, int location) {
Path p = new File(path).toPath();
String name = p.getName(location).toString();
return name;
}
public static void main(String[] args) {
String path = “project//doc//index.html”;
String result = displayDetails(path,2);
System.out.print(result);
}
}
What is the result?
A.
doc
B.
index.html
C.
an IllegalArgumentException is thrown at runtime.
D.
An InvalidPthException is thrown at runtime.
E.
Compilation fails.
B
B
The answer is B