Page 1 of 1

About Question enthuware.ocajp.i.v8.2.836 :

Posted: Sat Feb 04, 2017 2:49 pm
by skissh
The first option and given correct choice is: An abstract class can be extended by an abstract or a concrete class. This statement to be a correct choice the code must look like this: <<abstract class or concrete class>> extends <<abstract class>> {}. So far so good.

The 2 nd option and given correct choice is: A concrete class can be extended by an abstract or a concrete class. This statement codified would look like this: <<abstract class or concrete class>> extends <<concrete class>> {}. Can an abstract class be a subclass of a concrete class?

If "extended by" means the opposite of what I thought then the first option can't be correct. What does "extended by" mean? Can the words "extended by" be replaced by "a subclass of" or "a base class of"?

Re: About Question enthuware.ocajp.i.v8.2.836 :

Posted: Sat Feb 04, 2017 9:00 pm
by jamesmccreary
I'm glad I happened to stumble on this, I just reviewed this question when you posted as well.

You can think of it as EVERY class extending java.lang.Object (a concrete class). Thus an abstract class can extend a concrete class. If you want implementation, you simply need to extend this abstract class. So you can have the following

(2nd Concrete Class) extends (Abstract Class)
(Abstract Class) extends (1st Concrete Class)
(1st Concrete Class) extends (java.lang.Object)

Do note that you can only extend "one at a time" throughout the hierarchy tree. So the above three lines are 3 separate steps.

To answer your last question, yes, extends means "is-a". If Class B extends Class A, Class B is a sub-class (is-a) of A. Yes you can replace extends with "a subclass of". The extended class would be considered a "base" class however. Think of it as java.lang.Object as the trunk of a tree from which all the branches (other classes) extend from that same trunk. Further extensions (twigs) can only extend directly from one branch (their connection point).

Hope that helps!

Re: About Question enthuware.ocajp.i.v8.2.836 :

Posted: Sat Jan 20, 2024 9:36 am
by agupta108
B option should be incorrect, and should be replaced by the more correct E option

Re: About Question enthuware.ocajp.i.v8.2.836 :

Posted: Sat Jan 20, 2024 9:48 am
by admin
Why do you think option B should be incorrect?