Carey Brown wrote:A String is an Object. An Object may or may not be a String. If you try to pass an Object to a method expecting a String it won't work because it might not be a String. IF you KNOW it's a String, then you could cast the Object to a String when calling the method.
Glenn Jayasuriya wrote:But my question was how to tell if the object is a string?
Glenn Jayasuriya wrote:Because as I stated in the OP, the "instanceof String" returned true but it was a generic object.
Because a String is most specific than a Object, shouldn't it have returned false?
Glenn Jayasuriya wrote:What I mean is how can one verify that you have a generic object instead of a string?
Glenn Jayasuriya wrote:Had to review child classes but I get now that the parent class can contain an instance of a child class and at runtime acts like a String.
Glenn Jayasuriya wrote:Is there a difference between the word parent class and superclass? Child class and subclass?
From my understanding there really isn't much of a difference.
Glenn Jayasuriya wrote:Also isn't an object just a instance of a class?
So "object of a subclass type" is really an instance of subclass which is an instance of a child class which is what i wrote.