Abstract class scenario and difference between interfaces.

Asked By 0 points N/A Posted on -
qa-featured

Does anyone know in what exact situation one is supposed to declare a class as abstract?

How will I come to know the parameters that have been analyzed for a class to be abstract and how would I declare it abstract?

I would also like to know the difference between abstract class and interface.

SHARE
Best Answer by dainy
Best Answer
Best Answer
Answered By 0 points N/A #92850

Abstract class scenario and difference between interfaces.

qa-featured
  • Abstract classes are classes that contain one or more abstract methods.
  • An abstract method is a method that is declared, but contains no implementation.
  • Abstract classes may not be instantiate and require subclasses to provide implementations for the abstract methods.
  • Let's look at one example of an abstract class and an abstract method: by using abstract classes, you can inherit the implementation of other (non-abstract) methods.
  • You can't do that with interfaces because an interface cannot provide any implementation method.
Answered By 0 points N/A #92851

Abstract class scenario and difference between interfaces.

qa-featured

In program language, an abstract class has more than one or one functions that haven’t implemented and can’t be instantiated.

Functions are implemented when a class inherits from the abstract class.

The main benefit of claiming the abstract class is that an inherited derived-class could has its implementation for any unimplemented functions. Moreover, a derived class could inherit from different abstract classes.

The abstract class is very similar to the interface but some differences could be found between them, e.g. a derived class may implement unlimited interfaces, but could inherit from one abstract class only.

Moreover, an abstract class can comprise of several abstract properties, methods and any other members, but an interface could only contain abstract properties, default public and methods.

Please follow this link for more information: Abstract Class vs Interface

Regards,

Adam

Related Questions