wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C# Quiz #1

Total questions: 25

Worksheet time: 14mins

Name
Class
Date
1.

Which of the following statements about inheritance in C# is correct?

a)

A. A class in C# can inherit from multiple base classes.

b)

B. A class in C# can only inherit from interfaces, not other classes.

c)

C. A class in C# can inherit from one base class and implement multiple interfaces.

2.

Which of the following statements about inheritance in C# is true?

a)

A class in C# can inherit from multiple base classes.

b)

Inheritance in C# is only possible with abstract classes.

c)

A derived class inherits all members of the base class, including private members.

d)

A class can inherit from another class using the : symbol.

3.

Which access modifier allows a class member to be accessible in derived classes but not outside the class?

a)

public

b)

private

c)

protected

d)

internal

4.

Which of the following can be inherited in C#?

a)

Constructors

b)

Private fields

c)

Static methods

d)

Public and protected methods

5.

Can a class inherit from multiple classes in C#?

a)

Yes, using multiple colons

b)

No, C# does not support multiple inheritance of classes

c)

Yes, using the multiple keyword

d)

Only in .NET 7 or later

6.

Which keyword is used to prevent a class from being inherited?

a)

static

b)

abstract

c)

sealed

d)

readonly

7.

Given the classes below, what type of inheritance is shown?

class Vehicle { }

class Car : Vehicle { }

class Truck : Vehicle { }

a)

Single Inheritance
e

b)

Multilevel Inheritance

c)

Hierarchical Inheritance

d)

Multiple Inheritance

8.

What symbol is used to declare inheritance in C#?

(a)  

9.

In C#, inheritance allows a class to:

a)

Prevent objects from being instantiated

b)

Reuse properties and behaviors from another class

c)

Access system libraries automatically

d)

Contain multiple unrelated methods

10.

A derived class is one that:

a)

Provides services to a base class

b)

Inherits from another class

c)

Cannot have constructors

d)

Has no properties

11.

Which of the following is not inherited from a base class?

a)

Private Methods

b)

Public methods

c)

Protected methods

d)

Public properties

12.

The virtual keyword in a base class method indicates that:

a)

The method can be overridden by a derived class

b)

The method is static

c)

The method cannot be accessed outside the class

d)

The method is asynchronous

13.

If a derived class has its own version of a base class method, this is known as:

a)

Overriding

b)

Shadowing

c)

Hiding

d)

Encapsulation

14.

The act of creating a new instance of a class is called (a)   .

15.

What is the keyword used to import namespaces and libraries in C#?

a)

using

b)

namespace

c)

class

d)

public

16.

Which keyword is used to define a class in C#?

a)

using

b)

namespace

c)

class

d)

public

17.

What is the keyword used to make class members accessible from outside?

a)

public

b)

private

c)

static

d)

void

18.

Which keyword is used to define a method that returns nothing in C#?

a)

void

b)

int

c)

string

d)

bool

19.

Which keyword is used to define a constant in C#?

a)

const

b)

static

c)

var

d)

public

20.

is a name given to a storage area that is used to store values of various data types

a)

Visual Studio 2010 (VS)

b)

Namespace declaration

c)

variable

d)

Arithmetic Operators

21.

Example of Arithmetic Operators

a)

&&

b)

==

c)

+

22.
What would be the correct declaration for a 2-dimensional array
a)
int [ ] sales = new int[2,3];
b)
int [ , , ] sales = new int [2,3];
c)
int [ , ] sales = new int [ ];
d)
int [ , ] sales = new int [2,3];
23.

Write code that states: if coins equal 100 or 150 give an extra life. (Hint: need to know symbol for "or" and "equals".

a)

if (coins == 100 || coins == 150) { lives += 1; }

b)

if (coins = 100 % coins = 150) { lives += 1; }

c)

if (coins AND 100 OR coins AND 150) { lives += 1; }

d)

if (coins += 100 | coins += 150) { lives += 1; }

24.

The this keyword inside a class refers to:

a)

The base class

b)

The current instance of the class

c)

A static member

d)

The parent namespace

25.

To define an indexer, you use:

a)

indexer keyword

b)

this keyword with [ ]

c)

getIndex() method

d)

ArrayList inheritance