About Question enthuware.ocpjp.v8.2.1226 :

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

Moderator: admin

Post Reply
lexer24
Posts: 6
Joined: Wed Jun 22, 2016 8:06 am
Contact:

About Question enthuware.ocpjp.v8.2.1226 :

Post by lexer24 »

Hi,

Why option 4 - You want to define common method signatures in the class but force subclasses to provide implementations for such methods. is valid here?

In question enthuware.ocpjp.v8.2.1229, description for option 1 is - This is a valid reason for declaring an interface but not an abstract class. Generally, the purpose of an interface is to identify and declare just the behavior. Actual implementation can come later. While abstract class is used when a common implementation is also identified. In that respect, an abstract class actually provides less abstraction than an interface.
From this explanation comes that if we have just signatures and no common implementation it is better to use interface and not an abstract class.

Maybe it should be - You want to define common method implementation in the class but force subclasses to provide specific implementations for such methods instead? Or a sort of this?

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

Re: About Question enthuware.ocpjp.v8.2.1226 :

Post by admin »

Interfaces do not have subclasses. The option is talking about forcing the subclasses to implement the methods.
If you like our products and services, please help us by posting your review here.

lexer24
Posts: 6
Joined: Wed Jun 22, 2016 8:06 am
Contact:

Re: About Question enthuware.ocpjp.v8.2.1226 :

Post by lexer24 »

Thank you for the answer.

So can we consider the requirement "force subclasses to provide implementation" as implementation details?

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

Re: About Question enthuware.ocpjp.v8.2.1226 :

Post by admin »

I am sorry but I don't understand what you mean by
"force subclasses to provide implementation" as implementation details.
If you like our products and services, please help us by posting your review here.

crazymind
Posts: 85
Joined: Mon Dec 24, 2018 6:24 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1226 :

Post by crazymind »

admin wrote:
Wed Jun 22, 2016 8:32 am
Interfaces do not have subclasses. The option is talking about forcing the subclasses to implement the methods.

How do we call a class who implements an interface? This question is really tricky.

ncskiber
Posts: 2
Joined: Sun Mar 24, 2019 2:28 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1226 :

Post by ncskiber »

Hello!

I was thinking about option 2 or 4, but I was embarrassed at option 4 because of this situation:

Code: Select all

abstract class A {
     abstract void test ();
}

abstract class B extends A {};
Here “B” is a subclass of “A”. And "B" is also an abstract class that is not obliged to implement the method of the superclass "A". In other words, this is true for the first concrete subclass. The question was not precise wording.

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

Re: About Question enthuware.ocpjp.v8.2.1226 :

Post by admin »

It is only talking about a necessary condition (and not a sufficient one). If you want to define common method signatures in the class but force subclasses to provide implementations for such methods then you definitely need an abstract class. Having an abstract class may not be sufficient though.
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 52 guests