Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between object of an abstract class and list of objects of abstract class?

Tags:

c#

.net

We can't create objects of an abstract class, but we can create a List or an array of them. What is the difference?

like image 333
What Avatar asked Dec 25 '15 19:12

What


People also ask

What is object of abstract class?

Abstract class: is a restricted class that cannot be used to create objects (to access it, it must be inherited from another class). Abstract method: can only be used in an abstract class, and it does not have a body. The body is provided by the subclass (inherited from).

What is difference between abstract and abstract class?

abstract class a type of class that object can not be create it contain abstract or not abstract method while abstraction is mechanism of data hiding......... simply , abstract class implements abstraction for hiding complexity . Abstract class is a class with abstract methods & non abstract methods .

What is the difference between an abstract class and interface?

Abstract Class Vs. Interface: Explore the Difference between Abstract Class and Interface in Java. The Abstract class and Interface both are used to have abstraction. An abstract class contains an abstract keyword on the declaration whereas an Interface is a sketch that is used to implement a class.


1 Answers

A list or array is simply a place holder for a set of pointers, and you have NOT created instances of anything yet.

When you say Create Object - you mean create an instance - which you cannot do with an abstract class.

But you can create Lists or Arrays that point to them (and are EMPTY) - then you can move the pointers to 'real' instances of derived classes/objects

like image 54
Grantly Avatar answered Sep 19 '22 22:09

Grantly