ITPEC IP October 2019 Question 22

Topic: SoftwareAlso asked in March 2018 and November 2021

As shown in the directory structure below, when D3 marked by an asterisk (*) is the current directory, which of the following the appropriate directory path that can designate file A under directory D4 marked by an arrow? Here, a file is designated as follows:

[Method of file designation](1)A file is referenced as “directory name\⋯\directory name\file name”, where the directory names on the path are listed and separated with “\” in sequence, followed by the file name.(2)The current directory is represented by a period “.”.(3)A directory that is one level higher is represented by two periods “..”.(4)When the path name string begins with a backslash “\”, it is assumed that the root directory is omitted from the beginning of the string.(5)When the path name string does not begin with “\”, “.”, or “..”, it is assumed that “ .\” for the current directory is omitted from the beginning of the string.
D1D2D3D4D5

Explanation

..\D2\D4\A — go up from D3 to the common parent D1, then down through D2 to D4.

D3 and D2 are both directly under D1, so one .. takes the reference from D3 to D1. From D1, the path goes down to D2, then D4, and ends with the file name: ..\D2\D4\A.

Answer (b)

Why not others:

  • •(a) — the second .. moves above D1, where there is no D2 as shown
  • •(c) — it does not start with \, . or .., so by rule (5) it is read as .\D1\D2\D4\A, a D1 under D3, which does not exist
  • •(d) — by rule (5) it is read as .\D2\D4\A, looking for D2 under D3, but D2 is under D1

Key rule: A relative path climbs with .. to the nearest common ancestor of the current directory and the target, then names each directory on the way down.

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.