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

What does those terms actually mean included in the j.d.k i.6?

0 Answers  


What is the difference between static method and instance method in Java?

0 Answers   SwanSoft Technologies,


what is the collable collections in java?

2 Answers   Persistent,


If you do not want your class to be inherited by any other class. What would you do?

0 Answers  


Can arraylist hold different types java?

0 Answers  






How many types of design patterns are there?

0 Answers  


what is the output??????? public class multireturn { public(int assign x ( int x) { if(4==x) { return 7; } else if (7=x+3) { return 6; } return 5; } }

3 Answers   TCS,


How is it possible in java programming for two string objects with identical values not to be equal under the == operator?

0 Answers  


How to Create A Wapper Class in core Java and Why are Use in java?

2 Answers   Amdocs,


Explain the difference between runnable and callable interface in java?

0 Answers  


What is the difference between java and .Net?

39 Answers   Bosch,


write a program that list all permutations of ABCDEF in which A appears before B?

0 Answers   Nissan,


Categories