creating another interface which extends the required-to-implement one and adding a few extra methods is certainly not a problem. I did that (and passed).
But you should NOT change method signatures of given methods, so you can not add a throws-clause with a checked exception. That will result in automatic failure. You can always wrap a possible IOException in a RuntimeException and throw that exception instead. So you don't need to change the method signature
I left the supplied interface unchanged. You're in trouble if you change it.
I added my own methods to an extended interface.
I documented my reasons for adding the methods.
SCJP 6 , OCMJD 6 ,
Joined: Aug 14, 2010
Roel and Robert,
Thanks for your input, guys. Two questions, though. Did you format the provided interface with the appropriate Javadoc formatting or did you leave it? Also, with your extended interface, did you then implement both interfaces in your Data class? I am using the Data class as a facade, so all my methods from both these interfaces are in it, which from a test requirement standpoint required me to implement both interfaces (not just the extended one), though from a strictly coding perspective such a move is redundant.
If you extend the interface, then by implementing that interface you automatically implement the DB interface as well.
Joined: Aug 14, 2010
You are 100% correct. Thus my reason for saying it was redundant to implement both with "implements DB, InterfaceExtension". My issue is with the wording of the exam: "Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface: ". So yes, technically, when I implement my extended interface, the one from Oracle is automatically implemented. However, I don't want to be automatically failed because my project lacks " implements DB" in the code of my Data class. It is a trivial technicality given that DB does get implemented from implementing the interface that extends it. However, it's not worth risking me being failed over something silly that Oracle expects to be on in my code, regardless of what interfaces I have extended. In other words, I don't want to fail over one line of code. ;)
Hopefully Roel or Robert will clarify if they took the exam super literal (as I am) or if they passed by just coding: