Re: Hi



s kumar <sudhir.ku@xxxxxxxxx> wrote:
Why We can't instanate the Abstract class?

CK wrote:
Because it is abstract.

The point of the keyword "abstract" is to demand that a class be extended, and that programs use only one of the derived classes. This forces a programmer to derive a class from the abstract class in order to use it (not counting static members, of course).

It is part of the rules of the Java language that one cannot instantiate an abstract class. This enforces the "you must extend this class" rule.

--
Lew
.



Relevant Pages

  • Re: Abstract class or interface?
    ... I try to make the decision based on the relationship of the derived class to the base class. ... If the derived class "can act like" the type of the base class, I'd lean towards an interface. ... I understand the abstract class can have implementation in its methods and derived classes can only inherit one abstract class. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: array, xmlserializer and inheritance
    ... This is very similar to the Registry pattern ... > // This list will contain objects of derived classes - like B ... > I need to serialize class B with XmlSerializer but in the class A i ...
    (microsoft.public.dotnet.framework)
  • XmlSerializer and DefaultValue?
    ... handmade Xml parsing code, but am having a few small issues with ... default values and derived classes. ... public int AValue ...
    (microsoft.public.dotnet.xml)
  • array, xmlserializer and inheritance
    ... // This list will contain objects of derived classes - like B ... cannot define what type will go in the List (with XmlArrayItem) because ... That's me favorite shirt. ...
    (microsoft.public.dotnet.framework)
  • Re: oops questions c#
    ... classes.My base class cannot be a abstract class. ... explicitly implement an interface for all derived classes. ... Working on the assumption it is legit, a simple solution would be to mark the method as virtual in the base class and have it throw a NotImplementedException. ...
    (microsoft.public.dotnet.languages.csharp)