aspose file tools*
The moose likes Beginning Java and the fly likes Doubt regarding abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt regarding abstract class" Watch "Doubt regarding abstract class" New topic
Author

Doubt regarding abstract class

Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Hi

I know that DateFormat is an abstract class. So I cannot instantiate an object of this type. But then how can I say:



How come I can declare and construct an array of DateFormat type i.e a class that is abstract? How does the JVM differentiate between the object instantiation and an array constructed to hold abstract class type objects?


~ Mansukh
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18159
    
    8

That's like asking how the grocer differentiates between some eggs and the box used to put the eggs in. They are entirely different things.

Creating an array of type X doesn't create any objects of type X, it simply creates an object which could hold such objects. The entries of that array are all initialized to null.
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Paul Clapham wrote:That's like asking how the grocer differentiates between some eggs and the box used to put the eggs in. They are entirely different things.

Creating an array of type X doesn't create any objects of type X, it simply creates an object which could hold such objects. The entries of that array are all initialized to null.


Thanks Paul..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt regarding abstract class
 
Similar Threads
new keyword doubt in abstract class context
Conversion of String to Date
how do abstract classes like NumberFormat call the methods from their subclasses?
The 'DateFormat' abstract class
DateFormat.getDateInstance(int style)