Search Header Logo

C# Inheritance Quiz

Authored by Dnyaneshwar Chaudhary

Used 2+ times

C# Inheritance Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?