3.4 - Storage classes.


Back Button Home

3.4.1 - Auto, Extern, Static and Register Storage Classes.


1. Which storage class is the default for local variables in C?
  • (A) Static
  • (B) Register
  • (C) Auto
  • (D) Extern
Correct Answer: (C) Auto
2. Which storage class suggests storing variables in the CPU register for faster access?
  • (A) Static
  • (B) Auto
  • (C) Register
  • (D) Extern
Correct Answer: (C) Register
3. Which storage class allows a variable to retain its value between function calls?
  • (A) Static
  • (B) Auto
  • (C) Register
  • (D) Extern
Correct Answer: (A) Static
4. Which storage class is used to share variables between multiple files?
  • (A) Auto
  • (B) Static
  • (C) Register
  • (D) Extern
Correct Answer: (D) Extern
5. What is the initial value of an auto variable if not explicitly initialized?
  • (A) Zero
  • (B) Garbage value
  • (C) Null
  • (D) Undefined
Correct Answer: (B) Garbage value
6. What is the default initial value of a static variable in C?
  • (A) Garbage value
  • (B) One
  • (C) Zero
  • (D) Undefined
Correct Answer: (C) Zero
7. Which storage class cannot be used to declare global variables?
  • (A) Extern
  • (B) Auto
  • (C) Static
  • (D) Register
Correct Answer: (B) Auto
8. Where is a variable stored when declared with the register keyword?
  • (A) RAM
  • (B) Hard disk
  • (C) CPU register
  • (D) Cache memory
Correct Answer: (C) CPU register
9. Which storage class is used when a variable needs to be globally accessible but should retain its value throughout program execution?
  • (A) Auto
  • (B) Extern
  • (C) Static
  • (D) Register
Correct Answer: (C) Static
10. In which memory are variables of the auto storage class stored?
  • (A) Hard disk
  • (B) RAM
  • (C) CPU register
  • (D) Cache
Correct Answer: (B) RAM
11. Which of the following storage classes has local scope but global lifetime?
  • (A) Auto
  • (B) Static
  • (C) Extern
  • (D) Register
Correct Answer: (B) Static
12. Which storage class is often declared in a header file to allow sharing across multiple source files?
  • (A) Static
  • (B) Auto
  • (C) Extern
  • (D) Register
Correct Answer: (C) Extern
13. What is the default value for a variable declared with the extern keyword?
  • (A) Undefined
  • (B) Zero
  • (C) One
  • (D) Garbage value
Correct Answer: (B) Zero
14. Which keyword is used to declare a variable that retains its value between multiple function calls in C?
  • (A) Auto
  • (B) Static
  • (C) Register
  • (D) Extern
Correct Answer: (B) Static
15. Which storage class is limited in scope to the block where it is declared but does not lose its value once the block is exited?
  • (A) Static
  • (B) Auto
  • (C) Extern
  • (D) Register
Correct Answer: (A) Static
16. Which of the following storage classes is commonly used for performance optimization by storing variables in CPU registers?
  • (A) Auto
  • (B) Register
  • (C) Static
  • (D) Extern
Correct Answer: (B) Register
17. Which of the following storage classes allows variables to be accessed across different source files in a program?
  • (A) Auto
  • (B) Register
  • (C) Extern
  • (D) Static
Correct Answer: (C) Extern
18. Which keyword is optional when declaring a local variable in C?
  • (A) Register
  • (B) Extern
  • (C) Auto
  • (D) Static
Correct Answer: (C) Auto
19. Which type of variable cannot have its address taken due to its storage in the CPU register?
  • (A) Auto
  • (B) Register
  • (C) Static
  • (D) Extern
Correct Answer: (B) Register
20. Which storage class provides both global visibility and maintains its value throughout the entire program execution?
  • (A) Extern
  • (B) Auto
  • (C) Static
  • (D) Register
Correct Answer: (A) Extern