Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What if not all of the methods in the provided interface are implemented?  RSS feed

 
jason wong
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was wondering if all the methods defined in the interface MUST be implmented. That means for instance, since I'm not using the create method, I wouldn't have to implement it, just declare it in the data class as requested in the assignment.

Do this conform the requieremens asked by sun?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you are required to give a valid implementation of every method listed in the interface. However, you are not required to actually do anything inside the methods. For example, if one of the methods has a return type void, then all you have to have is an empty body of the method, and that is a valid implementation. If the method has a return type other than void, all you have to do is return a value that is compatible with the return type.
 
jason wong
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Keith!,

thanks a lot for your quick answer.
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I've a feeling you'd get a serious detraction in your score if you went that way.
Better implement and test everything on the database level, and then not use it all in the client.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!