This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes getInstacne() for an abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getInstacne() for an abstract class" Watch "getInstacne() for an abstract class" New topic
Author

getInstacne() for an abstract class

Grishma Dube
Ranch Hand

Joined: Jul 01, 2003
Posts: 275
Hi,
I have a very basic question. We cannot create instance of an abstract class.
e.g. Calendar class of util pkg is ab abstract class. so if we try to create an instace of this using new operator, it gives error.
However, we can call getInstance() method to get an instance of Calendar class. Can anyone explain me, what exactly happens when we call getInstance() method??
TIA
Grishma
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
The default is to create a new GregorianCalendar (which is not abstract).


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Note that GregorianCalendar is a subclass of Calendar. This is an example of Polymorphism in the Java 2 Standard Edition API. Another example can be found with the public void paint(Graphics g) method that many windowing components have.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getInstacne() for an abstract class
 
Similar Threads
An example of abstraction in java
java.util.Calender Abstract confusion
Abstract class Calendar
Calendar static final fields
abstract method puzzler