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 are the fields of vtable
Can you name some types of inheritance?
What do you mean by overloading?
pointers are support in C#? if yes then how to use it?
8 Answers Softvision Solution,
what is the difference between class and object?
What is difference between polymorphism and inheritance?
What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; } 1) The computer will output "0123...99" 2) The computer will output "0123...100" 3) The output is undefined
what is virtual function in c++
What is polymorphism in oops?
what is polymorphism?
what is the definition of incapsulation
how to write a java program for an output ****0 ***01 **012 *0123 01234