This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

John Hunt mock: Q30  RSS feed

 
Jared Cope
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I came across the following question:

What class must an inner class extend:

A. The top level class
B. The Object class
C. Any class or interface
D. It must extend an interface

Select the most appropriate answer.

The answer is listed as C. I think it should be B.

I think C is wrong because there is nothing to say that an inner class must extend at least one class, and furthermore a class can not extend an interface ever. I think B is correct cause every class is implicitly derived from Object.

Thoughts?

Jared.
 
Ken Weller
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C doesn't make sense to me at all, so I would also choose B for the same reason you indicated. That's a terribly worded question.
 
Vicken Karaoghlanian
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the question is worded using a must, then the correct answer would be 'B' as you pointed out. 'C' would be true iff we used may instead of must.

Another way to look to option 'C' is that a class can never EXTEND an interface, so this option is always false, regardless the use of must/may.

As you can see the question is not worded clearly, and don't expect such questions to appear in the real exam.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since it just says "inner class" and not "anonymous inner class," I agree: B should be the correct answer, for exactly the reasons you stated.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Object it is...

 
Swati Udas
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.. I also agree that B should be the correct answer!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!