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 |
In what situation factory design patterns,DAO design patterns,singleton design patterns should be applied.?
Are polymorphisms mutations?
Write a program in c++ to read two floating point numbers and find their sum and average.
Difference between new operator and operator new
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
What does and I oop mean?
what is Class in oops with example?
What is the output of the following code: int v() { int m=0; return m++; } int main() { cout<<v(); } 1) 1 2) 0 3) Code cannot compile
What is object in oop?
what is virtual destructor
why to use template classes in c++?
suppose A is a base class and B is the derved class. Both have a method foo which is defined as a virtual method in the base class. You have a pointer of classs B and you typecast it to A. Now when you call pointer->foo, which method gets called? The next part of the question is, how does the compiler know which method to call?