1).what is the difference between below examples

String s="vijay";

String s=new String("vijay");

Answer Posted / karun

In first statement String s = "vijay"

Means it will create a single instance and single reference
variable

but in second statement

String s = new String("vijay");

Means it will create a two instances and single reference
variable

Is This Answer Correct ?    4 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you escape a string?

493


What was java originally called?

495


Why we cannot override static method?

544


Garbage collection in java?

573


Difference between method overloading and overriding.

566






What is identifier give example?

539


What do you understand by synchronization?

578


What is the difference between synchronized and synchronized block?

492


Explain try and catch keywords in java?

609


What is the difference between compiler and jvm?

536


Find the value of a specified element of the array arr[i] where 0 <= i <= n-1

524


What is Java Annotations?

547


Explain about doubly linked list

604


What does %d do in java?

565


what is the difference between the methods sleep() and wait()? : Java thread

493