wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C# Programming Quiz

Total questions: 36

Worksheet time: 58mins

Name
Class
Date
1.

What statement allows selection based on multiple conditions?

a)

if-else

b)

switch

c)

else-if

d)

for

2.

Which keyword is used to create a structure?

a)

struct

b)

class

c)

record

d)

data

3.

Which method does NOT return a value?

a)

int getSum()

b)

void displayMessage()

c)

double computeArea()

d)

string getName()

4.

Which statement is used to stop the execution of a switch case?

a)

end

b)

exit

c)

stop

d)

break

5.

What keyword is used to define an interface?

a)

implements

b)

interface

c)

abstract

d)

class

6.

The ternary operator uses how many operands?

a)

1

b)

2

c)

3

d)

4

7.

What type of conversion requires a cast operator?

a)

Implicit

b)

Automatic

c)

Explicit

d)

Default

8.

Which of the following is a valid method overloading?

a)

Two methods with same name and parameters

b)

Same name, different return types

c)

Same name, different parameters

d)

Different name, same parameters

9.

A constructor:

a)

Returns a value

b)

Initializes objects

c)

Is optional in C#

d)

Can be static only

10.

An abstract class:

a)

Can be instantiated

b)

Cannot have methods

c)

Can define abstract methods

d)

Must implement an interface

11.

What is the default value of a bool variable?

a)

true

b)

1

c)

false

d)

null

12.

What is the syntax for declaring a constant?

a)

const int x;

b)

constant int x = 0;

c)

const int x = 10;

d)

var const x = 10;

13.

Which is a reference type?

a)

int

b)

double

c)

string

d)

bool

14.

What is the use of 'this' keyword?

a)

Refers to parent class

b)

Refers to derived class

c)

Refers to current object

d)

Refers to global variable

15.

What operator is used for conditional evaluation?

a)

==

b)

?:

c)

&&

d)

<>

16.

Method overriding uses which keyword in base class?

a)

static

b)

private

c)

virtual

d)

const

17.

A derived class inherits members using:

a)

comma

b)

equals

c)

colon

d)

dot

18.

Which access modifier makes members visible to derived classes only?

a)

private

b)

protected

c)

internal

d)

public

19.

What is the correct syntax for creating an object?

a)

new ClassName();

b)

ClassName obj = ClassName();

c)

ClassName obj = new ClassName();

d)

obj = new ClassName;

20.

What is the base class keyword in C#?

a)

super

b)

extends

c)

base

d)

parent

21.

A special method used to initialize objects.

4 lines
22.

A blueprint for creating objects.

4 lines
23.

A way to hide data from outside access.

4 lines
24.

Allows a class to inherit members of another class.

4 lines
25.

A class that cannot be instantiated.

4 lines
26.

A structure that stores value types.

4 lines
27.

It defines the members a class must implement but provides no implementation.

4 lines
28.

A short form of if-else used for decision making.

4 lines
29.

A keyword that refers to the current object instance.

4 lines
30.

A method declared with the same name but different parameters.

4 lines
31.

Give two (2) access modifiers in C#.

4 lines
32.

Give two (2) types of polymorphism.

4 lines
33.

Name two (2) members an interface can contain.

4 lines
34.

Give two (2) types of data types in C#.

4 lines
35.

List two (2) rules for naming identifiers.

4 lines
36.

Write a C# program that prints "I love C#" five times using a loop.

4 lines