Raisin cookies that look like chocolate chip cookies are the main reason I have trust issues.
Raisin cookies that look like chocolate chip cookies are the main reason I have trust issues.
Travis Roberts wrote:Wow, I can't believe I didn't see that. It's the little things that trip me up the hardest.
Raisin cookies that look like chocolate chip cookies are the main reason I have trust issues.
Raisin cookies that look like chocolate chip cookies are the main reason I have trust issues.
Travis Roberts wrote:
I guess what is confusing me is I read that an object inherits all methods in its ancestral line and in the case of
I have called the m() inside class B (right?) but have passed it a class A object. The m() inside class B accepts only B objects as parameter. I expected it to call the method inside class A.
Travis Roberts wrote:
And this line of code is even more confusing because I have called the method inside class A and passed it a class B object. Class A does not inherit from B. In this case I expected the compiler to blow up.
I am utterly confused.
Henry Wong wrote:
Travis Roberts wrote:
And this line of code is even more confusing because I have called the method inside class A and passed it a class B object. Class A does not inherit from B. In this case I expected the compiler to blow up.
I am utterly confused.
Class B extends class A... so doesn't that means that an instance of class B IS-A instance of class A? An instance of B is supposed to work everywhere that expects an A, so why should it "blow up"?
Henry
Raisin cookies that look like chocolate chip cookies are the main reason I have trust issues.
Travis Roberts wrote:
aObj.m(bObj);
Does the reference variable aObj not matter?
Henry Wong wrote:
Travis Roberts wrote:
aObj.m(bObj);
Does the reference variable aObj not matter?
What do you mean by "not matter"? As already mentioned in a previous post, the compiler uses the type to determine the method to call. And since it is a class A instance, it will call the m() method that takes a class A instance, as that is the only method that matches.
Henry
Raisin cookies that look like chocolate chip cookies are the main reason I have trust issues.
Travis Roberts wrote:
Yes, but I am passing in an instance of B class, and the m() method in the A class accepts a A class object as a parameter, not B class..
Don't get me started about those stupid light bulbs. |