Sunday, 20 April 2014

Java


(1) What is factory method and give some Examples ?
The Jave method that is capable of constructing it's own java class object is called factory method.Most of all factory methods are static methods
Ex 1 :  Thread t = Thread.currentThread() ;
The java.lang.Thread.currentThread() method returns a reference to the currently executing thread object.
 Ex 2 : String st = String.valueOf(20):
 String.valueOf(20) Returns the string representation of the int argument 
 Ex 3 : Class c = Class.forName(String className);
 java.lang.Class.forName(String className)  method returns the Class object for the class with the specified name.
Ex 4 : Calendar cal = Calendar.getInstance() ;
Calendar.getInstance() returns a Calendar 
Categories: ,

0 comments:

Post a Comment