This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Java OCA/OCP 8 Programmer Practice Tests: OCP Practice Exam, Q #84  RSS feed

 
Greenhorn
Posts: 7
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
84. What is the output of the following application?

Answer:
   D. One line of code does not compile.

But the answer should be:
   E. Two lines of code do not compile.
MyElectricBass class is also inheriting the problem from the ElectricBass class.
By compiling this code we can see the 2 compilation errors showing up:

Regards,
 
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we not have two of the same default methods in separate interfaces? Only in the case we implement both interfaces? good question. I wasnt aware of this. if someone can elaborate. I will try to compile also
 
Juan Pablo Barale
Greenhorn
Posts: 7
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a class is implementing two interfaces with the same default method (firm), the class doesn't know which implementation to use, so you are forced to override it in order to compile.
The same problem occurs in the case an interface extends two interfaces with the same default method.
 
author & internet detective
Posts: 39129
723
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ugh. I tested the example. In Eclipse, it shows one compiler error and at the command line it shows two.  Which means the exam could ask about the first line that gives an error, but now how many (because it is ambiguous).

I added an item in the errata to say consider D or E to be correct.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!