Question discussion

Which two of the following are legal declarations for abstract classes and interfaces?1. final abstract class Test {}2. public static inter…

309148Medium 1 reply 2,398 views
15
Which two of the following are legal declarations for abstract classes and interfaces?1. final abstract class Test {}2. public static interface Test {}3. final public class Test {}4. protected abstract class Test {}5. protected interface Test {}6. abstract public class Test {}
  • A1 and 2
  • B2 and 4
  • C3 and 5
  • D5 and 6
  • E3 and 6
Correct answer: E

Discussion 1

0
CCommunity
3 and 6

(3), (6). Both are legal class declarations.

(1) is wrong because a class cannot be abstract and final "there would be no way to use such a class". (2) is wrong because interfaces and classes cannot be marked as static. (4) and (5) are wrong because classes and interfaces cannot be marked as protected.