File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Factory methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Factory methods" Watch "Factory methods" New topic
Author

Factory methods

Chetan Dodiya
Ranch Hand

Joined: Jun 27, 2008
Posts: 39
I came across one question...
Which classes are always instantiated via Factory method???
a, java.util.Date
b, java.util.Locale
c, java.util.Calender
d, java.text.DateFormat
e, java.text.NumberFormat

this q is from of K & B book....
what is the Factory method???/
which is the correct answer???


SCJP 1.5
Preethi Dev
Ranch Hand

Joined: Sep 07, 2008
Posts: 265
c,d,e are always instantiated via the static factory methods getInstance(),getDateInstance(),getCurrencyInstance(). These classes are abstract. So we are using these methods to instantiate them.

preparing Scjp1.5
Chetan Dodiya
Ranch Hand

Joined: Jun 27, 2008
Posts: 39
but what is factory method???
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9304
    
  17

Factory methods are methods which return instances of a class. Just as a factory produces items, Factory method produces instances. The general naming convention for factory methods is getInstance.

eg



SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Factory methods