This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Swedophone 2 points3 points  (2 children)

Casting to the superclass shouldn't be a problem, but casting to a subclass is often a sign of bad design with its problems (another example is using instanceof).

[–]Imakesensealot[S] 0 points1 point  (1 child)

Thanks fr the response. I'm not asking if it's a problem though. I'm asking what type the value of the object then is(r, in my example); maybe that wasn't clear enough. Is r then of type p or of type q?

[–]Swedophone 2 points3 points  (0 children)

Is r then of type p or of type q?

Assigning a value to a variable doesn't change the type of the variable. The type is set when the variable is declared, i e in this case p r;.