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
Can we create object of abstract class?
What is the types of inheritance?
What is encapsulation with example?
How do you use inheritance in unity?
What is an advantage of polymorphism?
What is pure oop?
to find out the minimum of two integer number of two different classes using friend function
What makes a language oop?
What is object in oops?
What is abstract class in oops?
• What are the desirable attributes for memory managment?
What is the difference between procedural programming and oops?
What are the 3 pillars of oop?
What is coupling in oops?
What is oops concept with example?