Hi there, I'm preparing for an interview with a company, and I came across this question earlier and was wondering peoples' thoughts on it.
I have a fairly solid programming background, but not so much with Java, and as multiple inheritance is not allowed in Java, how would you respond to this question?
Given a class A and another (B) that inherits from it, if you have a method that casts B to A and invokes a method x() that both A and B implement, which class's implementation is invoked?
At first look, I'm not entirely sure how to answer this. Since I am usually programming in C#, I do believe this would throw an exception, but since this is Java, after some brushing up, wouldn't it be appropriate to say, "since neither A or B are implementing an interface, it would throw an exception?"
Any help/thoughts would be greatly appreciated!!