C# Inheritance Quiz

C# Inheritance Quiz

5 Qs

quiz-placeholder

Similar activities

Fibre to Fabric-Class 7 {10 q's}.

Fibre to Fabric-Class 7 {10 q's}.

7th Grade

10 Qs

ปริมาณและการวัดทางกายภาพ

ปริมาณและการวัดทางกายภาพ

12th Grade - University

10 Qs

OOP2 Understanding Inheritance in OOP

OOP2 Understanding Inheritance in OOP

11th Grade

10 Qs

Population Structure (Pyramids)

Population Structure (Pyramids)

8th - 12th Grade

10 Qs

Inheritance

Inheritance

Professional Development

10 Qs

What is Democracy?Why Democracy?

What is Democracy?Why Democracy?

9th Grade

10 Qs

Python Zybooks Module 13 - Inheritance

Python Zybooks Module 13 - Inheritance

University

10 Qs

OOps VB

OOps VB

Professional Development

10 Qs

C# Inheritance Quiz

C# Inheritance Quiz

Assessment

Quiz

Medium

Created by

Dnyaneshwar Chaudhary

Used 1+ times

FREE Resource

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

In C#, which keyword is used to define a class that inherits from another class?

A. base

B. extend

C. inherit

D. : (colon)

2.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What is the term for a class that cannot be instantiated and is only meant to be inherited from in C#?

A. Final class

B. Base class

C. Abstract class

D. Sealed class

3.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Which keyword in C# is used to prevent a class from being inherited by other classes?

A. abstract

B. static

C. sealed

D. override

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What will be the output of the following code?

class Country

{

    public virtual void country()

    {

        Console.WriteLine("India");

    }

}


class India : Country

{

    public new void country()

    {

        Console.WriteLine("Best");

    }

}


Country india=new Country();

Country India=new India();

India country=new india();

india.country();

India.country();

country.country();

A. "India"

"India"

"Best"

B. "India"

"Best"

"Best"

C. "Best"

"India"

"Best"

D. Compilation Error

5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Suppose you have a base class Shape and two derived classes Circle and Rectangle. How would you implement method overriding in C# to calculate the area for each shape?

A. Use the base keyword in the derived class methods.

B. Use the new keyword in the derived class methods.

C. Use the virtual keyword in the base class and override keyword in the derived classes.

D. Use the override keyword in the base class and virtual keyword in the derived classes.