+ 7
How many objects are created in the below == > String s = new String("Welcome");
String s = new String("Welcome"); Hit like and post your answer
8 Respostas
+ 13
Trust Me..it's proved
The correct answer is 2 Objects created.
1st Object== "Welcome" is a String literal and every String literal itself is an Object in Java.
2nd Object== String class Object created using new String ()
The first Object "Welcome" is created in STRING CONSTANT POOL and one more "Welcome" Object is stored outside the POOL.
+ 5
This is a tricky question many people failed to answer it correctly..
+ 3
1?
+ 3
Welcome is picked up from constant pool using ldc, and the String constructor is called
+ 1
closer to self taught badge ;)
+ 1
2
0
1
- 1
There are 2 objects for sure.