What is the result?

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?

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)
-> home

subpath(0,2)

Reference: The Java Tutorial, Path Operations



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Jav

Jav

C
getName(0): education
subpath (0, 2): education\institute