Given the code fragment:
Which code fragment, when inserted at line n1, enables the code to print /First.txt?
Given the code fragment:
Which code fragment, when inserted at line n1, enables the code to print /First.txt?
To enable the code to print '/First.txt', the correct code fragment to be inserted at line n1 is 'Path iP = Paths.get("/", "First.txt");'. This is because the correct way to get a Path object in Java is by using the static 'get' method of the 'Paths' class. The 'Paths.get' method can take multiple string arguments to construct the path. Therefore, option D is correct.
D,tested
D is correct. Path is instantiated using Paths class and method get.