How can u create the Object of class Without using "New"
opertor?
Answer Posted / giridhar gangapatnam
There are 4 ways to create object:
1.using new operator
Employee obj=new Employee();
Except this one
2.using factory methods
NumberFormat obj=NumberFormat.getNumberInstance();
3.using newInstance() method
Class c=Class.forName("Employee");
Employee obj=(Employee)c.newInstance();
or we can write these two lines as a single line
Employee obj=
(Employee)Class.forName("Employee").newInstance();
4.By cloning
Employee obj1=new Employee();
Employee obj2=(Employee)obj1.clone();
| Is This Answer Correct ? | 20 Yes | 4 No |
Post New Answer View All Answers
List some important characteristics on jre
Why is singleton instance static?
Which is bigger float or double?
What do you mean by compiler?
What is multithreading and its advantages?
Can an object be null?
Will set allow duplicates in java?
Can we use synchronized block for primitives?
What is the type of lambda expression?
What is not object oriented programming?
How big is a gigabyte?
What does I ++ mean?
Why java is considered dynamic?
Can abstract class have private constructor?
How do you find the independent variable?