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 the example of polymorphism?
What is abstraction in oops with example?
Write 7 differences between "Public" function and "Private" function?
What do we mean by a hidden argument in C++?
How long to learn object oriented programming?
what is the difference between a package and a software?
What are the benefits of polymorphism?
What is the real time example of inheritance?
Write a program to sort the number with different sorts in one program ??
Can we call a base class method without creating instance?
Program to open a file with First argument
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?