1).what is the difference between below examples

String s="vijay";

String s=new String("vijay");

Answer Posted / navneet raushan

the first case does: if u write first case , one object and
one refernce will be created. object will be created in
string pool.
But when u write 2nd case , two object and one refernce
will be created , one in string pool and one in heap.

Is This Answer Correct ?    1 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages and disadvantages of object cloning?

747


Is oracle charging for java?

747


What is null in java?

687


Explain about map interface in java?

765


Differentiate between postfix and prefix operators in java.

848






Why array is used in java?

681


What is an empty class? What functionality does it offer in Java?

927


Can a class with private constructor be extended?

672


What is a buffer in computer?

689


Is call by reference possible in java?

712


What are the various access specifiers in java?

725


Give an example of use of pointers in java class.

736


Explain how hashmap works?

775


What are the different http methods?

708


What do u mean by variable?

768