GATE | GATE-CS-2004 | Question 9

Consider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2, the reference will be resolved at
(A) Edit-time
(B) Compile-time
(C) Link-time
(D) Load-time


Answer: (C)

Explanation:  

Note:
Static linking is done at link-time, dynamic linking or shared libraries are brought in only at runtime.

(A) Edit-time : Function references can never be given/determined at edit-time or code-writing time. Function references are different from function names. Function names are used at edit-time and function references are determined at linker-time for static libraries or at runtime for dynamic libraries.

(B) Compile-time : Compile time binding is done for functions present in the same file or module.

(C) Link-time : Link time binding is done in the linker stage, where functions present in separate files or modules are referenced in the executable.



(D) Load-time : Function referencing is not done at load-time.

Hence, correct answer would be (C).

 

This solution is contributed by Vineet Purswani.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.