How can u create the Object of class Without using "New"
opertor?

Answers were Sorted based on User's Feedback



How can u create the Object of class Without using "New" opertor?..

Answer / mohan reddy

In 3 ways we can able to create object without using "new"
operator.

1)Using a Static Factory Method
ABC.getInstance();
2)Using newInstance() method...
class A=(A)Class.forName("A").newInstance();
3)Using clone() method.

Is This Answer Correct ?    38 Yes 7 No

How can u create the Object of class Without using "New" opertor?..

Answer / 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

How can u create the Object of class Without using "New" opertor?..

Answer / seshu godavarthi

when the class is declared as static we can create an
object for the class without instantiating or without using
new operator...we can access the variables or methods in
the class by using the classname

Is This Answer Correct ?    6 Yes 1 No

Post New Answer

More Core Java Interview Questions

Advantages of Inheritance in java.

11 Answers   CybAge, HCL,


How big is a gigabyte?

0 Answers  


What does java se mean?

0 Answers  


Why deletion in linkedlist is fast than arraylist?

0 Answers  


What is inner class?what is the use of inner class?where we create the object for inner class? and inner class can extend any class or inner class can implement any interface?

1 Answers   Wipro,






What is javac in java?

0 Answers  


What mechanism does java use for memory management?

0 Answers  


what is difference between type 4 driver and type 1 driver?

2 Answers   CMC, CTS, IBM, JK Technosoft, Napier Healthcare,


What is meant by wrapper classes?

3 Answers  


In the below example, how many string objects are created?

0 Answers  


When is an object in the mean to garbage collection?

3 Answers  


Why do we use public static with the main function in Java?

13 Answers   College School Exams Tests, Infosys,


Categories