Since you seem new to java i will explain in detail,
When you write this basketball o, s;
in java , it means you are creating two reference variables of type basketball. What a reference variable means is , it is a type of variable that can point to the actual object of basketball.
When you write this s = new basketball();
in java it means, You are creating a new object in java , and assigning that object to the reference variable. This means you are providing a link to the object through s
Imagine this, the reference variable as a remote control and the object (instance variable) as a TV. Although all the real work is done by TV , the control of entire TV is done through the remote control. Its a link to the TV for the user.
so When you do o = s;
, you are assigning the object (instance variable) pointed by s
to o
. Hence now both s
and o
point to the same object. And hence When changes are made on one it obviously will reflect on the other. Imagine it like having two remote controls for the same TV.
For your answer , Only one object is created , but two references are created.