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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
skissh
Posts: 7
Joined: Tue Jan 31, 2017 4:16 pm
Contact:

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

Post 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"?

jamesmccreary
Posts: 22
Joined: Sun Jan 15, 2017 10:51 pm
Contact:

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

Post 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!

agupta108
Posts: 4
Joined: Sat Jan 20, 2024 9:26 am
Contact:

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

Post by agupta108 »

B option should be incorrect, and should be replaced by the more correct E option

admin
Site Admin
Posts: 10066
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Why do you think option B should be incorrect?
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 240 guests