• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrong Answer for question 11, Page 294 (Java OCA 8 Programmer I Study Guide)

 
Suresh Regmi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is asking for modifiers, but the results is wrong because it includes the optional specifiers(static and final) as well.

page 294, question number 11 ==> correct answer should only be A.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suresh Regmi wrote:The question is asking for modifiers, but the results is wrong because it includes the optional specifiers(static and final) as well.

page 294, question number 11 ==> correct answer should only be A.

No, you are wrong on this one, the book is spot-on!

The question asks for modifiers and you have 2 flavors: access and nonaccess modifiers. And variables defined in an interface are inherently public, static and final. So these are ALL optional modifiers, because you can define a variable in an interface without any modifierThis interface will compile successfully and variable MESSAGE is public, static and final

Hope it helps!
Kind regards,
Roel
 
Suresh Regmi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roel for the Reply, but I do not agree with your answer. The book explicitly refers Access modifier and Optional Specifier in Chapter 4, page 167 and 168. Also check the answer for question number 1, you will understand what I mean.

anyways appreciated.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suresh Regmi wrote:The book explicitly refers Access modifier and Optional Specifier in Chapter 4, page 167 and 168. Also check the answer for question number 1, you will understand what I mean.

First of all, I don't see how the answer for question #1 can make me understand what you mean. In an interface (in Java 8) methods are only implicitly public so that makes sense that B is the only correct answer.

From page 274 (middle of page)
Java OCA 8 Programmer I Study Guide wrote:As we see in this example, the compiler will automatically insert public static final to any constant interface variables it finds missing those modifiers.
Q.E.D.

Kind regards,
Roel
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question #1 is about what modifiers are applied to all interface methods. Not which ones can be used with interface methods. If you write void method() in an interface, what is it automatically. The book correctly lists one modifier for this. Question #11 is about what modifiers are applied to all interface variables. There is more than one correct answer to this. I agree with Roel. The book is correct.

The confusion might be a "Americans write sloppy English" thing. Both optional specifiers like final and access modifiers like public are types of modifiers. Since the exam creators are also American and write English "loosely", it is good you encountered this confusion in our book and not on the exam!
 
Suresh Regmi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank Jeanne and Roel for the Reply.

from question number 11, I now agree that there will be two types of modifiers(Access and Non-Access). For non-access the book has called optional specifiers.

But, Still not satisfied with the answer of question number 1 page 291. the correct answer should have been(B, E). If you refer to the book on page number 268.

void fly(int speed); JVM will automatically(implicitly) add the modifiers to make
public abstract void fly(int speed);

Question number 1 asks about the same modifiers that will be applied to interface methods.

 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suresh Regmi wrote:But, Still not satisfied with the answer of question number 1 page 291. the correct answer should have been(B, E). If you refer to the book on page number 268.

void fly(int speed); JVM will automatically(implicitly) add the modifiers to make
public abstract void fly(int speed);

That's indeed true for this method! (And it's true for all interface methods prior to Java 8 as well). But in Java 8 you'll have something new like default interface methods. And question #1 asks for modifiers applied to interface methods without any further specification, so that could be a "regular" interface method or a default interface method. Therefore the only modifier which is assumed, is the public access modifier. And definitely not the abstract nonaccess modifier, because that's not assumed for a default interface method (as such a method already has an implementation, a method body).

In conclusion: for both questions #1 and #11 the book is spot-on!

Hope it helps!
Kind regards,
Roel
 
Suresh Regmi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Roel again for you kind reply. I was thinking the interface methods and default interface methods were little different. My assumption was there was a difference, if we are including the default interface methods, then the Book is correct.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic