difference between String a; and String a=new String();?
y do v need to assign memory to the variable?

Answer Posted / janardhan

String a; :---

JVM will create String object in SCPM(String constant pool
memory)only.

String a=new String();:---

JVM will create String object in two memories
1. Heap memory
2. String constant pool memory.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we declare a class static?

764


What are mutable classes?

744


What is the purpose of methodology?

859


Explain the features of interfaces in java?

768


Why spring singleton is not thread safe?

771


What will be the initial value of an object reference which is defined as an instance variable?

920


Why super is first line in java?

838


What was java originally called?

731


Why is multiple inheritance not supported in java?

794


Why we used vector class?

843


What is the difference between object oriented programming language and object based programming language?

776


Write a method that will remove given character from the string?

800


What is difference between == equals () and compareto () method?

760


What are the two environment variables that must be set in order to run any java programs?

742


What is the use of toarray () in java?

807