what is difference between
String s=new String("vali");
String s="vali"
Answer / 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 |
What is OOPS and How it is different from Procedural Programming ?
23 Answers HP, Infosys, Thyrocare,
What do you mean by multiple inheritance and multilevel inheritance? Differentiate between them.
what is overloading and overriding?
Why do while loop is used?
what is single inheritance?
What do we mean by a hidden argument in a function?
What language is oop?
What is encapsulation?
write a program that takes input in digits and display the result in words from 1 to 1000
What is object and class in oops?
What is the difference between a constructor and a destructor?
what is polymorpsim? what are its types?