This site requires JavaScript, please enable it in your browser!
Greenfoot back
Ahmed780
Ahmed780 wrote ...

2020/5/4

What does this mean?

Ahmed780 Ahmed780

2020/5/4

#
I am confused about this question.I think the answer is either a or b. please help me Water water; a.Object called water b.Data Type called water c.Error, water is duplicated d.Variable name water
ninjapuffin ninjapuffin

2020/5/4

#
what are you trying to do? the answer depends on that.
danpost danpost

2020/5/4

#
The statement:
Water water;
is a variable declaration statement. It declares a variable, called water, that is of type Water. That is, water will only be used to reference an object of type Water (aka: a Water instance). It is not being assign any object at this time and therefore will take on a default value of null. So, (d). I did not include (a) because no object is yet referenced by the variable. I did not include (b) because water is an object reference to a Water instance -- not a Type instance. I declined on (c) because you would need to declare water again at the same level for that error to occur.
You need to login to post a reply.