Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP 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

 
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
 
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!