Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How can you prevent classes to be inherited?

Answers were Sorted based on User's Feedback



How can you prevent classes to be inherited?..

Answer / vijay sharma

We can prevent classes to be inherited by marking the
classes as sealed.

Is This Answer Correct ?    24 Yes 0 No

How can you prevent classes to be inherited?..

Answer / jaffer

By using Sealed keyword before class.

Is This Answer Correct ?    9 Yes 0 No

How can you prevent classes to be inherited?..

Answer / nitin kumar tomar

just make the class sealed like

sealed public class classname

Is This Answer Correct ?    6 Yes 0 No

How can you prevent classes to be inherited?..

Answer / chvramana

Using Keyword Sealed. You can created Sealed class and
You can prevent the class to be inherited.

Is This Answer Correct ?    6 Yes 0 No

How can you prevent classes to be inherited?..

Answer / usha

make the class as sealed class

Is This Answer Correct ?    5 Yes 0 No

How can you prevent classes to be inherited?..

Answer / dhiraj kumar pandey

We can prevent classes to be inherited by using the key
word SEALED.

Is This Answer Correct ?    5 Yes 0 No

How can you prevent classes to be inherited?..

Answer / asit nutiyal(birla)

sealed modifier is used for preventing the accident
inhritance of a class. A sealed class can not be inhrited.

Example :

using system;

sealed class abc
{
protected string str = "";

public virtual void hello()
{
str = " Hi i am not in C#";
}
class xyz : abc //--ERROR--
{
public override void hell0()
{
str = "hi i am in C#";
Console.WriteLine("{0}",str);
}
}
class mainclass
{
public static void Main()
{
xyz x = new xyz();
x.hello();
}
}

Note-> if we run above program thn we will get an error
because we inheit class abc while it is sealed.

Is This Answer Correct ?    4 Yes 0 No

How can you prevent classes to be inherited?..

Answer / dhara

we can prevent class to be inherite by making sealed class
by using keyword sealed.

Is This Answer Correct ?    2 Yes 0 No

How can you prevent classes to be inherited?..

Answer / nagesh rajarapu

by using sealed keyword before the class name

Is This Answer Correct ?    0 Yes 0 No

How can you prevent classes to be inherited?..

Answer / lucky

make the constructor private.

Is This Answer Correct ?    0 Yes 14 No

Post New Answer

More C Sharp Interview Questions

Do while loops yes or no c#?

0 Answers  


What are Generics?

5 Answers   TCS,


What are static and dynamic variables?

0 Answers   CGI,


Can we have static indexer in c#?

0 Answers  


what are some characteristics of an array?

0 Answers  


Can an interface extend a class c#?

0 Answers  


How you will create satellite assemblies?

0 Answers  


What is a class c#?

0 Answers  


Can we inherit singleton class in c#?

0 Answers  


When you inherit a protected class-level variable, who is it available to?

5 Answers   CMC, IBM,


What is the data type for bit in c#?

0 Answers  


Can abstract class have constructor in c#?

0 Answers  


Categories