Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Confusing Answers from Wiley test bank of book OCA/OCP Java SE 8 Practice Tests  RSS feed

 
Max Ma
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is like this:

what is the output of the following application?


intuitively, I spotted the anonymous class  implementation has problem, but in my Eclipse environment, it also complaints on the overriding method public void swim(){System.out.println();} by stating that  "illegal modifier for the variable siwm.

Could please any one help? why I got two lines failed to compile?
error.png
[Thumbnail for error.png]
compilation error
 
Max Ma
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the correct answer given was one line of compilation error.

answer.png
[Thumbnail for answer.png]
answer from test bank
 
Roel De Nijs
Sheriff
Posts: 11338
177
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
I would assume that the creation of the anonymous inner class of the CanSwim interface is wrong (line9). Once you have fixed that error, the code will compile successfully.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!