Functions Quiz - CBSE Class 11 ICT
Free practice quiz: Functions (CBSE Class 11 ICT). 20 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 20 questions freeSample questions
What is a function in programming?
- A block of code that performs a specific task
- A type of variable
- A data structure
- A loop
Show answer
Answer: A. A block of code that performs a specific task
A function is a reusable block of code designed to perform a specific task. It improves code organization and readability.
Explain the difference between a function's definition and a function's call.
- There is no difference
- Definition executes the function; call only declares it
- Definition declares the function; call executes it
- Definition is an input; call is an output
Show answer
Answer: C. Definition declares the function; call executes it
The function definition describes what the function does. The function call is the action of using it.
What is the scope of a variable declared inside a function?
- Global scope
- Local scope
- Static scope
- Dynamic scope
Show answer
Answer: B. Local scope
Variables declared inside a function have local scope; they are only accessible within that function.
What is the difference between pass-by-value and pass-by-reference when passing arguments to a function?
- Pass-by-value creates a copy; pass-by-reference uses the original
- Pass-by-value modifies the original; pass-by-reference creates a copy
- There is no difference
- Pass-by-value is faster, pass-by-reference is slower
Show answer
Answer: A. Pass-by-value creates a copy; pass-by-reference uses the original
Pass-by-value creates a copy of the argument, while pass-by-reference uses the original variable's memory location.
Discuss the advantages and disadvantages of using recursive functions.
- Advantages: Simplicity, Disadvantages: None
- Advantages: Efficiency, Disadvantages: Complexity
- Advantages: Simplicity, Disadvantages: Potential stack overflow
- Advantages: Speed, Disadvantages: Readability
Show answer
Answer: C. Advantages: Simplicity, Disadvantages: Potential stack overflow
Recursive functions can elegantly solve certain problems, but excessive recursion can lead to stack overflow errors.