1. What is the primary advantage of dynamic linking over static linking?
A) It increases the size of the executable
B) It allows updating shared libraries without recompiling the program
C) It is faster to load at runtime
D) It reduces the complexity of the program
Answer: B) It allows updating shared libraries without recompiling the program
2. Which of the following is true about dynamic loading?
A) The libraries are linked at compile-time
B) It occurs when the program is loaded into memory for execution
C) The program loads all the libraries before execution
D) The program uses static libraries only
Answer: B) It occurs when the program is loaded into memory for execution
3. In dynamic linking, when is the linking of external functions or libraries performed?
A) At compile-time
B) At load-time
C) At run-time
D) At program shutdown
Answer: C) At run-time
4. Which of the following best describes dynamic linking?
A) It refers to linking libraries at compile-time, reducing runtime dependencies
B) It refers to linking libraries at runtime, which reduces the memory footprint
C) It happens when the linker places all code into the executable file
D) It is used to perform memory management tasks
Answer: B) It refers to linking libraries at runtime, which reduces the memory footprint
5. What is the role of the dynamic linker in dynamic linking?
A) To directly compile the source code into machine code
B) To load and link the dynamic libraries at runtime
C) To resolve all external references at compile-time
D) To manage memory allocations for the executable
Answer: B) To load and link the dynamic libraries at runtime
6. Which of the following is not a benefit of dynamic linking?
A) Reduced executable size
B) Allowing the sharing of code among multiple programs
C) Easier program updates without recompiling
D) Improved runtime performance
Answer: D) Improved runtime performance
7. In dynamic loading, how is a function or library loaded into memory?
A) It is loaded by the operating system at startup
B) It is loaded explicitly by the program using system calls or library functions
C) It is automatically loaded by the compiler
D) It is linked during program compilation
Answer: B) It is loaded explicitly by the program using system calls or library functions
8. Which of the following can be a drawback of dynamic linking?
A) It increases the size of the executable
B) It can cause compatibility issues if the library changes between versions
C) It makes the program less flexible
D) It leads to more memory usage compared to static linking
Answer: B) It can cause compatibility issues if the library changes between versions
9. What happens when a dynamically linked program calls a function from a shared library?
A) The function is resolved at compile-time
B) The program directly uses the function from the static library
C) The dynamic linker resolves the function at runtime
D) The function is ignored by the program
Answer: C) The dynamic linker resolves the function at runtime
10. Which of the following is typically used in dynamic loading to load a shared library at runtime?
A) exec()
system call
B) loadLibrary()
or dlopen()
C) link()
system call
D) linkDynamic()
function
Answer: B) loadLibrary()
or dlopen()
11. What is a dynamic library (also known as a shared library)?
A) A library linked into the program at compile-time
B) A library that is executed along with the program
C) A library that is loaded and linked into the program during execution
D) A library that is embedded directly into the program’s source code
Answer: C) A library that is loaded and linked into the program during execution
12. Which of the following is not a characteristic of dynamic linking?
A) Linking happens at runtime
B) Shared libraries can be updated independently
C) Code from the library is copied into the executable
D) The program size can be reduced
Answer: C) Code from the library is copied into the executable
13. Which of the following is a typical use case for dynamic linking?
A) Creating a large executable with all libraries included
B) Linking a program with the operating system kernel
C) Sharing common code (like system libraries) among multiple programs
D) Directly embedding third-party libraries into the program code
Answer: C) Sharing common code (like system libraries) among multiple programs
14. Which of the following is true regarding dynamic loading in comparison to static loading?
A) Dynamic loading increases the initial loading time of the program
B) Dynamic loading makes the program size larger
C) Dynamic loading cannot unload libraries
D) Dynamic loading occurs before the program begins execution
Answer: A) Dynamic loading increases the initial loading time of the program
15. How does dynamic linking affect memory usage?
A) It uses more memory than static linking
B) It reduces memory usage by sharing libraries among processes
C) It has no impact on memory usage
D) It requires more memory because each process gets its own copy of the library
Answer: B) It reduces memory usage by sharing libraries among processes
16. Which of the following is an example of dynamic linking in Windows?
A) .lib
files
B) .obj
files
C) .dll
files
D) .exe
files
Answer: C) .dll
files
17. What is the difference between dynamic linking and static linking in terms of executable size?
A) Static linking produces smaller executable files
B) Dynamic linking produces smaller executable files
C) Both produce executables of the same size
D) Static linking produces no executable files
Answer: B) Dynamic linking produces smaller executable files
18. In dynamic linking, what does the linker do when a program calls a function from a shared library?
A) It resolves the function call at compile-time
B) It calls the function directly from the library without checking the program
C) It links the function to the program at runtime when the call occurs
D) It does not resolve the function at all
Answer: C) It links the function to the program at runtime when the call occurs
19. Which of the following is a system call used to dynamically load libraries on Unix-like operating systems?
A) malloc()
B) exec()
C) dlopen()
D) fopen()
Answer: C) dlopen()
20. Which of the following statements is true about the dynamic linking process in modern operating systems?
A) It is always slower than static linking
B) It reduces the overall disk space required for multiple programs
C) It always requires the program to be recompiled
D) It increases the size of each program individually
Answer: B) It reduces the overall disk space required for multiple programs