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 |
for example A,B,C,D are class all the 4 class contain one method who() but the method who() implementaion is differnet among each class. the relation among the 4 class are A is base class and is inherited by B and C.and from this two B and C where D is inherited. the question is i want to display the output who() method in all the classes(A,B,C,D)the output of who() method is diferrent amond all the class(A,B,C,D) ------A------ virtuval who(print a) override | | who(print b) B C override who(print c) | | -------D------ override who(print d)
• What are the desirable attributes for memory managment?
what are the ways in which a constructors can be called?
difference between static and non-static variables?
Can you explain polymorphism?
What is the full form of oops?
what is the function of 'this' operator ?
Where is pseudocode used?
Difference between over loading and over ridding?
12 Answers CTS, Patni, Softvision Solution,
Whatis the difference between oop and object based language
write a progra in c++ using class & object to find out wheather a given no. is prim or not.
What is destructor example?