Recall & Review
beginner
What is method overloading in C#?
Method overloading is when multiple methods in the same class have the same name but different parameters (different type, number, or order). It helps perform similar actions with different inputs.Click to reveal answer
beginner
Can two overloaded methods have the same parameter types and order but different return types?
No. Overloaded methods must differ in their parameter list. Return type alone cannot distinguish overloaded methods.
Click to reveal answer
beginner
Why use method overloading?
It makes code easier to read and use by allowing the same method name to handle different types or numbers of inputs, like a real-life tool with multiple functions.
Click to reveal answer
intermediate
Example: What does this code do?
public int Add(int a, int b) { return a + b; }
public double Add(double a, double b) { return a + b; }
It defines two Add methods: one adds two integers, the other adds two doubles. The right method is chosen based on the input types.
Click to reveal answer
intermediate
What happens if you call an overloaded method with arguments that match more than one method signature?
The compiler gives an error because it cannot decide which method to use. You must make the call unambiguous.
Click to reveal answer
Which of these is a valid method overloading example?
✗ Incorrect
Methods must differ in parameters, not just return type. Only option B has different parameter types.
What must differ between overloaded methods?
✗ Incorrect
Overloaded methods share the same name but must have different parameters.
What happens if overloaded methods have the same parameters and return type?
✗ Incorrect
Duplicate method signatures cause a compilation error.
Why is method overloading useful?
✗ Incorrect
It allows one method name to handle different inputs clearly.
Which is NOT a valid difference for method overloading?
✗ Incorrect
Return type alone cannot distinguish overloaded methods.
Explain method overloading and why it is helpful in programming.
Think about how one tool can do many jobs depending on how you use it.
You got /5 concepts.
Describe what rules must be followed to create overloaded methods in C#.
Focus on what makes each method unique to the compiler.
You got /4 concepts.