ITPEC IP April 2024 Question 17

Topic: Software

In a file system with the hierarchy structure shown in the Figure, when “..\..\DIRB\Fn.txt” is specified from the directory marked with an * (the current directory), which of the following is the file that is referenced? Here, blank in the Figure show the directory name, and the reference method for a file is as below.

[Reference method](1)A file is referenced as “directory name\ ⋯ \directory name\file name”, where the directory names on the path are listed with a separator “\” in sequence, followed by “\” and the file name.(2)The current directory is represented by “.” (a period).(3)The directory one (1) level above is represented by “..” (two periods).(4)When a reference begins with a “\”, it is assumed that the leftmost root directory has been omitted.
RootDIRBDIRADIRADIRBDIRBDIRB(1)Fn.txt(2)Fn.txt(3)Fn.txt(4)Fn.txt*

Explanation

Fn.txt at (4) — up two levels to the DIRB directly under Root, then down into its subdirectory DIRB.

The current directory, the one marked with an asterisk, is Root\DIRB\DIRA\DIRB. Resolve ..\..\DIRB\Fn.txt one part at a time:

PartNow at
startRoot\DIRB\DIRA\DIRB
..Root\DIRB\DIRA
..Root\DIRB
DIRBRoot\DIRB\DIRB
Fn.txtthe file directly in Root\DIRB\DIRB, which is (4)

Answer (d)

Why not others:

  • •(a) — (1) is in the current directory itself, .\Fn.txt; the two .. steps leave it
  • •(b) — (2) is directly in Root\DIRB, where the two .. steps end; reaching it would take ..\..\Fn.txt, without the DIRB step
  • •(c) — (3) is one level deeper, in Root\DIRB\DIRB\DIRB; reaching it would take ..\..\DIRB\DIRB\Fn.txt

Key rule: Resolve a relative path left to right from the current directory: each .. goes up one level and each name goes down into that child, so the same name at different levels is a different directory.

Software · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official IP past-paper collection or Report an issue.