answersLogoWhite

0

What are factory methods in java?

Updated: 12/23/2022
User Avatar

Wiki User

13y ago

Best Answer

A factory class is any class which is used to create instances of other classes. The methods which create those classes are the factory methods.

For example, the BorderFactory class has a variety of methods for creating instances of the different types of the Border classes.

BorderFactory.createEmptyBorder();

BorderFactory.createEtchedBorder();

...

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are factory methods in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is it possible to override overloaded methods why?

Yes. Overloaded methods are also Java methods and all Java methods can be overridden.


Explain three different methods in java?

There are three different methods /functions in java are there : 1)computational methods.2)manipulative methods.3)procedural methods.


What is a java object?

A java object is a collection of methods and properties defined in the Java programming language.


The actions in a java class are called?

The actions in a java class are called methods.


What makes up a Java class?

Fields and methods. Fields are variables defined at the class level, i.e., they are available for all methods. Methods are the equivalent of functions / procedures, but they are defined for a specific class.


Who invoke main function in java?

The Java Runtime Environment invokes main methods.


What is the use of functions in java?

Same as in other languages. To organize commands into logical pieces. However, in Java the functions are called "methods". This is related to the fact that in Java, methods or functions are defined as part of a class.


How nesting of methods is done in java?

No, Java only allows a method to be defined within a class, not within another method.


What are duplicate java method names?

overloaded methods.


What implicit modifiers interface methods have in java?

public


What is the purpose of java methods?

go ask your monitor.


What is factory methods?

Factory methods are merely a convention whereby static methods in a class return an instance of that class. The InetAddress class has no visible constructors. In InetAddress the 3 factory methods getLocalHost, getByName, getAllByName can be used to create instances of InetAddress.