what is difference between
String s=new String("vali");
String s="vali"

Answer Posted / kartik sharma

In case of String s=new String("vali"); , a memory in the heap is allocated to the variable of the class String, and then the value is given to the variable s="vali". Using new operator , we can allocate the memory to the instance of the class.


But in String s="vali" , only the variable s is given the value as vali but there is no permanent memory given to the variable in heap.

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does no cap mean?

779


What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?

1886


What are the data types in oop?

818


Prepare me a program for the animation of train

2213


c++ program to swap the objects of two different classes

2115


How does polymorphism work?

857


What is encapsulation in ict?

803


What are the important components of cohesion?

737


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

1823


What is constructor in oop?

814


What does and I oop and sksksk mean?

861


Get me a number puzzle game-program

1924


What polymorphism means?

805


What is polymorphism give a real life example?

756


what is the drawback of classical methods in oops?

3105