+ 2

Can we instantiate with out using new operator ,if yes than how?

6th Jan 2020, 12:48 PM
Prathvi
Prathvi - avatar
3 Antworten
+ 3
Only when you use the "new" keyword, an object is instantiated and the memory is allocated in the heap. But for successive object creation you can assign the previous object to a new reference variable. Edit: String class is an exception.
6th Jan 2020, 1:18 PM
Avinesh
Avinesh - avatar
6th Jan 2020, 3:06 PM
Denise Roßberg
Denise Roßberg - avatar
0
Object obj=obj2; Here obj2 is another object... Using up casting, down casting is an examples.. And both objects points to same references in heap.
6th Jan 2020, 1:05 PM
Jayakrishna 🇮🇳