Quiz Yourself: C# Basics
Check your understanding of C# case sensitivity, syntax rules, type casting, and control flow structures.
We'll cover the following...
We'll cover the following...
C# Basics Quiz
1.
Why would the following method definition result in a compiler error?
static int CalculateSum(int a, int b)
{
int sum = a + b;
if (sum > 100)
{
return sum;
}
}
A.
The return type int implies a value is optional, but the code forces a return.
B.
The variable sum is defined locally and cannot be returned to the calling method.
C.
The method parameters a and b must be defined as static to be used in the logic.
D.
The return statement is inside a conditional block, leaving other paths without a return value.
1 / 14