Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 is polymorphism and its types?

1127


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

2356


Why is polymorphism needed?

1126


Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer

2204


Why is it so that we can have virtual constructors but we cannot have virtual destructors?

5054


What is super in oop?

1260


What is difference between abstraction and encapsulation?

1134


What is encapsulation in ict?

1119


What is abstract class in oop?

1065


What is the oops and benefits of oops programming?

1030


Can you explain polymorphism?

1157


What is the difference between encapsulation and polymorphism?

1155


What is overloading in oop?

1050


What is the point of polymorphism?

1094


What is destructor give example?

1117