PrepAway - Latest Free Exam Questions & Answers

Which of the following is TRUE with regards to sealed classes?

You work as a developer at ABC.com. The ABC.com network consists of a single domain named
ABC.com.
You have been tasked with creating an application for ABC.com. The written code includes a
sealed class.
Which of the following is TRUE with regards to sealed classes? (Choose all that apply.)

PrepAway - Latest Free Exam Questions & Answers

A.
It cannot be instantiated.

B.
It cannot be used as a base class.

C.
It provides a common definition of a base class that multiple derived classes can share.

D.
It is used to prevent derivation.

Explanation:

4 Comments on “Which of the following is TRUE with regards to sealed classes?

  1. frank says:

    B and D because keyword “Sealed” applied on Class is opposite of “Abstract Class”.
    It’s used on class to means that “This class can not be Derived from”.
    So this class can not be used as base class and derivation is not allowed.




    0



    0
  2. Chinmay says:

    We can create an object of a class marked as sealed
    sealed class Program
    {
    public void add(int a, int b)
    {
    int c = a + b;
    Console.WriteLine(c);

    }
    public static void Main(string[] args)
    {
    Program p = new Program();
    p.add(4, 5);

    Console.ReadLine();
    }
    }
    The program runs without any error.So its possible to create object of sealed class
    B & D




    0



    0

Leave a Reply