WorksheetsC# Programming Quiz
Total questions: 36
Worksheet time: 58mins
What statement allows selection based on multiple conditions?
if-else
switch
else-if
for
Which keyword is used to create a structure?
struct
class
record
data
Which method does NOT return a value?
int getSum()
void displayMessage()
double computeArea()
string getName()
Which statement is used to stop the execution of a switch case?
end
exit
stop
break
What keyword is used to define an interface?
implements
interface
abstract
class
The ternary operator uses how many operands?
1
2
3
4
What type of conversion requires a cast operator?
Implicit
Automatic
Explicit
Default
Which of the following is a valid method overloading?
Two methods with same name and parameters
Same name, different return types
Same name, different parameters
Different name, same parameters
A constructor:
Returns a value
Initializes objects
Is optional in C#
Can be static only
An abstract class:
Can be instantiated
Cannot have methods
Can define abstract methods
Must implement an interface
What is the default value of a bool variable?
true
1
false
null
What is the syntax for declaring a constant?
const int x;
constant int x = 0;
const int x = 10;
var const x = 10;
Which is a reference type?
int
double
string
bool
What is the use of 'this' keyword?
Refers to parent class
Refers to derived class
Refers to current object
Refers to global variable
What operator is used for conditional evaluation?
==
?:
&&
<>
Method overriding uses which keyword in base class?
static
private
virtual
const
A derived class inherits members using:
comma
equals
colon
dot
Which access modifier makes members visible to derived classes only?
private
protected
internal
public
What is the correct syntax for creating an object?
new ClassName();
ClassName obj = ClassName();
ClassName obj = new ClassName();
obj = new ClassName;
What is the base class keyword in C#?
super
extends
base
parent
A special method used to initialize objects.
A blueprint for creating objects.
A way to hide data from outside access.
Allows a class to inherit members of another class.
A class that cannot be instantiated.
A structure that stores value types.
It defines the members a class must implement but provides no implementation.
A short form of if-else used for decision making.
A keyword that refers to the current object instance.
A method declared with the same name but different parameters.
Give two (2) access modifiers in C#.
Give two (2) types of polymorphism.
Name two (2) members an interface can contain.
Give two (2) types of data types in C#.
List two (2) rules for naming identifiers.
Write a C# program that prints "I love C#" five times using a loop.
