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
What is a short in java?
What kind of variables can a class consist?
What is meant by vector class, dictionary class, hash table class, and property class?
explain autoboxing in java?
What are the types of sockets in java?
What is operator overloading. Is it is supported in java?
What is Applet Stub Interface ?
What is java abstraction with example?
Is there any difference between nested classes and inner classes?
Is void a keyword in java?
Can list be final in java?
Can static methods access instance variables in java?
What steps are taken when the OS shifts from one-thread execution to another?
What is set and get methods in java?
Can constructor be synchronized?