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
What is pointer in oop?
Can we have inheritance without polymorphism?
What is difference between pop and oop?
What is property in oops?
how to get the oracle certification? send me the answer
class type to basic type conversion
What are properties in oop?
What is static modifier?
What is an advantage of polymorphism?
How is class defined?
Can a destructor be called directly?
What is the use of oops?
What is encapsulation selenium?
Write a c++ program to display pass and fail for three student using static member function
can inline function declare in private part of class?