0
Does an object created under a static method also becomes static?
7 Respostas
+ 1
Sagar Gupta try to come up with a code which you did not understand or something similar because it will be difficult to answer a question with a broad scope. I might not be able to give an accurate answer is all I'm saying.
Hope you understand.
+ 3
Yes, obj has the address of object.
To assign address of another object to obj, you can simply write : obj=new Object () ;
Check out this code for better understanding :
https://code.sololearn.com/cE2u3qNKqFJ3/?ref=app
+ 2
No, an object created inside a static method doesn't become static by default and is similar to normal instantiation.
You use the static keyword to make a reference variable static.
+ 1
Understand the difference between a reference and an actual object.
Object obj = new Object();
Here obj is a reference and new Object() is the actual object which is created in the heap memory.
0
Thanks avinesh..i have so much of confusion like which all classes and methods can use an object created in a particular class ?
0
Avinesh so this reference obj1 has address of new object()? And what if we want to assign a new address to same obj1?
0
Himani hey thanks, but can obj point at object of another class object apart from the class its already refering to? And also tell me what are normal class instances used for? Like if simple we create an instance temp p; ...what is the significance of this p.