1. Which of the following parameter passing methods passes the actual value of the argument to the function?
A) Pass by reference
B) Pass by value
C) Pass by pointer
D) Pass by name
Answer: B) Pass by value
2. In which of the following parameter passing methods is the actual parameter modified within the function?
A) Pass by value
B) Pass by reference
C) Pass by pointer
D) Pass by constant
Answer: B) Pass by reference
3. Which of the following is a characteristic of pass by reference?
A) The value of the argument is copied into the function’s parameter
B) The memory address of the argument is passed to the function
C) The function cannot modify the argument value
D) The function receives a constant copy of the argument
Answer: B) The memory address of the argument is passed to the function
4. What is the main disadvantage of pass by value?
A) It allows the function to modify the argument’s value
B) It can cause data corruption
C) It requires more memory for copying the argument value
D) It results in slower execution
Answer: C) It requires more memory for copying the argument value
5. Which of the following parameter passing methods is typically used in C++ for modifying the original value of the argument?
A) Pass by value
B) Pass by reference
C) Pass by address
D) Pass by constant reference
Answer: B) Pass by reference
6. In pass by value, if the argument is a large structure, what happens?
A) The function receives a reference to the structure
B) The function modifies the original structure
C) The function gets a copy of the structure, using more memory
D) The function fails to receive any argument
Answer: C) The function gets a copy of the structure, using more memory
7. Which parameter passing method is used in C when we pass the address of an argument using a pointer?
A) Pass by value
B) Pass by reference
C) Pass by address (pass by pointer)
D) Pass by constant reference
Answer: C) Pass by address (pass by pointer)
8. What is the main advantage of pass by reference?
A) It requires less memory
B) It avoids the need to copy large structures or arrays
C) The function cannot modify the argument
D) It allows passing constant arguments only
Answer: B) It avoids the need to copy large structures or arrays
9. In pass by pointer, how can the called function modify the actual argument?
A) By changing the value of the pointer itself
B) By changing the value stored at the memory address pointed to by the pointer
C) By copying the pointer’s value to a local variable
D) By returning a modified value from the function
Answer: B) By changing the value stored at the memory address pointed to by the pointer
10. Which of the following is true about pass by constant reference?
A) The function cannot modify the argument
B) The function receives a copy of the argument
C) It uses more memory than pass by value
D) The function can modify the argument but not return it
Answer: A) The function cannot modify the argument
11. In which parameter passing method does the function receive the address of the argument?
A) Pass by reference
B) Pass by value
C) Pass by pointer
D) Pass by constant reference
Answer: C) Pass by pointer
12. Which parameter passing method is used in Java for passing arguments to methods?
A) Pass by value for all types
B) Pass by reference for all types
C) Pass by reference for primitive types
D) Pass by value for primitive types and by reference for objects
Answer: D) Pass by value for primitive types and by reference for objects
13. In pass by reference, if the argument is a large data structure, which of the following happens?
A) A copy of the structure is passed to the function
B) A reference to the original structure is passed, so it can be modified
C) The function receives a constant copy of the structure
D) The program will fail to compile
Answer: B) A reference to the original structure is passed, so it can be modified
14. Which of the following is not true about pass by value?
A) It prevents the function from modifying the actual argument
B) It can be inefficient for large objects or data structures
C) It allows passing arguments by reference
D) It creates a new copy of the argument for the function
Answer: C) It allows passing arguments by reference
15. Which of the following methods of parameter passing is most efficient for large arrays?
A) Pass by value
B) Pass by reference
C) Pass by pointer
D) Pass by constant reference
Answer: B) Pass by reference
16. In pass by value, what happens if the function attempts to modify the argument?
A) The function successfully modifies the original value
B) The function cannot modify the original value, as only a copy is passed
C) The program crashes due to memory access violation
D) The original value is modified only if the argument is a pointer
Answer: B) The function cannot modify the original value, as only a copy is passed
17. Which parameter passing method is typically used for constant data that should not be modified inside a function?
A) Pass by reference
B) Pass by pointer
C) Pass by constant reference
D) Pass by value
Answer: C) Pass by constant reference
18. Which of the following methods of parameter passing can be used for passing arrays in C?
A) Pass by value
B) Pass by reference
C) Pass by pointer
D) Both B and C
Answer: D) Both B and C
19. Which of the following statements is true for pass by reference in C++?
A) It makes a copy of the argument
B) It allows the function to modify the argument’s value
C) It is slower than pass by value
D) It requires the use of the const
keyword for read-only arguments
Answer: B) It allows the function to modify the argument’s value
20. In pass by pointer, how can a function return the modified value of the argument?
A) By using the return
statement to return the modified argument
B) By modifying the value at the memory location pointed to by the pointer
C) By creating a new pointer and returning it
D) By copying the argument to the stack memory
Answer: B) By modifying the value at the memory location pointed to by the pointer