
Sealed vs Virtual in C#
Authored by Praise A
Information Technology (IT)
12th Grade

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
23 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The virtual keyword in C# indicates that a method:
Can be overridden by a derived class
Cannot be overridden
Must be implemented by every subclass
Is only accessible within the same assembly
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The purpose of a virtual method is to:
Provide a default implementation that derived classes can change
Force all derived classes to implement the method
Prevent inherited classes from accessing the method
Allow only static access to the method
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following keywords is used in a derived class to replace the behavior of a virtual method?
override
base
extends
implements
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
When overriding a method, what happens if you call base.MethodName()?
It creates a new instance of the base class
It calls the original implementation from the base class
It removes the overridden implementation
It hides the method from derived classes
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which keyword prevents further overriding of a virtual or overridden method?
sealed
static
const
readonly
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens if a derived class tries to override a sealed method?
The base version runs automatically
The compiler produces an error
The override is ignored silently
The override only applies at runtime
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The ability to override virtual methods in subclasses is an example of which object-oriented principle?
Polymorphism
Encapsulation
Aggregation
Composition
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?