ITPEC IP October 2025 Question 18
In a web server, five (5) directories have a hierarchical structure as shown in the figure below. In an HTML document stored in directory B, which of the following references the file img.jpg stored in the directory E? Here, directories and files are referenced using the method described below.
[Method of referencing directories and files]
(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)The directory one level above is represented by “..” (two (2) periods).(4)When a reference begins with a “/”, it is assumed that the root directory has been omitted from the beginning of the reference.(5)When a reference does not start with “/”, “.” (a period), or “..” (two (2) periods), it is assumed that “./” for the current directory has been omitted from the beginning of the reference.Explanation
../D/E/img.jpg — from directory B, go up one level to A, then down through D to E.
The HTML document is in B, so B is the current directory. In the tree, A has the subdirectories B and D, B contains C, and D contains E. To reach E:
- •
..moves from B up to its parent, A - •
Dis a subdirectory of A - •
Eis a subdirectory of D, whereimg.is storedjpg
Answer (b)
Why not others:
- •(a) ../A/D/E/img.jpg —
..already lands in A; the path then looks for a directory A inside A, which does not exist (/A/D/E/img., from the root, would work)jpg - •(c) ./A/D/E/img.jpg — looks for a directory A inside B; B contains only C
- •(d) ./D/E/img.jpg — looks for D inside B, but D is B's sibling, reached only by going up to A first
Key rule: Resolve a relative path one step at a time from the current directory: .. moves to the parent, . stays put, and each name moves down into a child.
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.