About Question enthuware.ocpjp.v8.2.1823 :

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

Moderator: admin

Post Reply
Sergey
Posts: 39
Joined: Sat Jul 29, 2017 1:04 pm
Contact:

About Question enthuware.ocpjp.v8.2.1823 :

Post by Sergey »

If we cannot override the final method (mA), how is it possible to call it from TestClass?

Code: Select all

o1.mA(); //4

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

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

Post by admin »

Why do you think final has anything to do with access?
If you like our products and services, please help us by posting your review here.

Sergey
Posts: 39
Joined: Sat Jul 29, 2017 1:04 pm
Contact:

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

Post by Sergey »

We instantiate object of Encyclopedia:

Code: Select all

Book o1 = new Encyclopedia (); //3
After we want to 'execute' method:

Code: Select all

o1.mA(); //4
But since type of reference is Book, we need that class Book has mA method. It really has it. But we must `execute` this method from Encyclopedia object, and since this method (in Encyclopedia object) is not compile, how could we `execute` it?

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

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

Post by admin »

Sorry but I am not sure what you mean by "and since this method (in Encyclopedia object) is not compile". Can you be a bit more clear about what you mean by this so that I can address your confusion?

Remember that final just means that a subclass cannot override it. It doesn't mean the subclass cannot access it or can not inherit it. This is OCAJP stuff :)
If you like our products and services, please help us by posting your review here.

Sergey
Posts: 39
Joined: Sat Jul 29, 2017 1:04 pm
Contact:

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

Post by Sergey »

I just try to understand if the line //2 will cause compilation to fail, then how could we run method o1.mA()? Since this method is fail to compile. By this logic the line //4 should not compile too?
I have passed OCA (81%) :)))

Sergey
Posts: 39
Joined: Sat Jul 29, 2017 1:04 pm
Contact:

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

Post by Sergey »

In other words, how could we run something if this "someting" is not compiled?

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

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

Post by admin »

Sergey wrote:In other words, how could we run something if this "someting" is not compiled?
Line marked //2 doesn't compile because it is trying to override a final method. There is no problem with line marked //4 because Encylopedia inherits method mA() from Book.
If you like our products and services, please help us by posting your review here.

Sergey
Posts: 39
Joined: Sat Jul 29, 2017 1:04 pm
Contact:

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

Post by Sergey »

Thanks. Now it is clear. It (method mA()) cannot be overridden but it inherited.

Post Reply

Who is online

Users browsing this forum: No registered users and 232 guests