Difference between static and abstract class?? RRS feed

All replies

  • A static class only has static methods and cannot be instantiated.

    An abstract class has at least one abstract method and can only be used as a base class for another class - it cannot be instantiated directly.

    Convert between VB, C#, C++, & Java (
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

    Monday, March 26, 2018 2:27 PM
  • Hello,

    This is the difference between static and abstract class :

    • Static Class: Declared with Static keyword, methods in Static Class are also static along with variables of the class.
      This class cannot be instantiated, i.e we cannot have objects of this class. To access methods of this class, you can directly use classname.method. Also this class cannot be inherited.

    • Abstract Class: Declared with abstract keyword, this class is primarily created as a Inheritable class. An abstract class enables other classes to inherit from this class, but forbids to instantiate. One can inherit from an abstract class but we cannot create objects of an abstract class. Abstract class can have abstract as well as non abstract methods. Abstract methods are those which are not having method definition.
    Monday, March 26, 2018 2:31 PM
  • A static class does not have any instance. Which means you can directly access public methods and properties by class names as following:

    YourClass.AnyMethod(); //For retrieving Function
    YourClass.AnyProperty; //To Get Public Members of the class

    For abstract class you need at least one abstract method and you can use it only as base class.

    Monday, March 26, 2018 5:43 PM