Forums Register Login

Question#3 in K&B book question

+Pie Number of slices to send: Send
Question #3 in K&B book

Given the following,
1. abstract class A {
2. abstract short m1() ;
3. short m2() { return (short) 420; }
4. }
5.
6. abstract class B extends A {
7. // missing code ?
8. short m1() { return (short) 42; }
9. }
which three of the following statements are true? (Choose three.)

A. The code will compile with no changes.
B. Class B must either make an abstract declaration of method m2() or implement
method m2() to allow the code to compile.
C. It is legal, but not required, for class B to either make an abstract declaration of method
m2() or implement method m2() for the code to compile.
D. As long as line 8 exists, class A must declare method m1() in some way.
E. If line 6 were replaced with �class B extends A {� the code would compile.
F. If class A was not abstract and method m1() on line 2 was implemented, the
code would not compile.

answer ACE

Is F also an answer because if class A was not abstract, class B cannot extend the concrete class because it is also abstract. compile error

Thanks
+Pie Number of slices to send: Send
No, an abstract class can extend a concrete class. If you think about it, the original abstract class A extended Object which is a concrete class.
+Pie Number of slices to send: Send
Thanks
Bras cause cancer. And tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 727 times.
Similar Threads
This abstract method surprised me--Kathy&Bert Book
A question from K & B book
Question on Declarations and Modifiers
K&B book Chapter 2 Self Test Question No.3
RE:Question from K&B book
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:56:04.