• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface and class question  RSS feed

 
Bob Ivanovich
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I was doing some practice tests I was confused on the following question:



Here are statements that may be true:

I. The interface is defined correctly, but the classes are all incorrect.
II. The classes are defined correctly, but the interface is incorrect.
III. The Spiderman class must extend X_Man in order to be correctly defined
IV. The Spiderman class must implement Superhero in order be correctly defined.

Which of the statements is/are true?
a) I and II are false, III and IV are true.
b) I is false, II, III, and IV are true.
c) IV is true, I, II, and III are false.
d) They are all false.
e) They are all true.

The answer sheet says it's "d." I thought it was "a."

Why would extending X_Man or implementing Superhero be incorrect?
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob Ivanovich wrote:Why would extending X_Man or implementing Superhero be incorrect?

Neither is necessarily incorrect, as an option. But it's incorrect to say you must do these things. The Spiderman class will compile and run just fine as written. It probably should implement Superhero, as a good common-sense design, but it isn't required to do so.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please always tell us where such questions come from.

That sort of question is confusing; it relies on double‑negatives.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!