How to create an instance of a class without using "new"
operator? Plz help me out properly.Thank u.

Answer Posted / b s vidyasagar reddy

three types
1.using factory methods
NumberFormat obj = NumberFormat.getNumberInstance();
2. using newInstance() method
class c = class.forName("Employee");
Employee obj = c.newInstance();
3. using coloning:
coloning is a way to create Bitwise exactcopy of an
existing object
Employee e2=e1.clone();

Is This Answer Correct ?    32 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is keyset in java?

829


Why is String immutable?

816


What are variable names?

700


How java enabled high performance?

785


Is 0 an even number?

740


What are methods in java?

721


What are namespaces in java?

722


What are the 5 types of research methods?

853


What is a static class in java?

729


What is the difference between sleep and wait in java?

707


Explain the importance of finalize() method.

741


When is update method called?

869


What are the string methods in java?

795


What is a lambda expression ? What's its use ?

782


What is meant by local variable and instance variable?

806