Given the code fragment:
public class App {
public static void main (String [] args){
Path path = Paths.get(“C:\\education\\institute\\student\\report.txt”);
System.out.println(“get.Name(0): %s”, path.getName(0));
System.out.println (“subpath(0, 2): %s”, path.subpath (0, 2));}
}
What is the result?
A.
getName (0): C:\
subpath (0, 2): C:\education\report.txt
B.
getName(0): C:\
subpth(0, 2): C:\education
C.
getName(0): education
subpath (0, 2): education\institute
D.
getName(0): education
subpath(0, 2): education\institute\student
E.
getName(0): report.txt
subpath(0, 2): insritute\student
Explanation:
Example:
Path path = Paths.get(“C:\\home\\joe\\foo”);
getName(0)
-> homesubpath(0,2)
Reference: The Java Tutorial, Path Operations
C
getName(0): education
subpath (0, 2): education\institute