Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes define new methods in DBMain Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "define new methods in DBMain" Watch "define new methods in DBMain" New topic
Author

define new methods in DBMain

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 910
    
    3
May I add getRecords() to DBMain to load all database records?
Instruction.htlm doesn't say I can't.
Any recommends?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 6354
    
  22

As far as I know you are not allowed to change the given interface. But you can of course create your own interface which extends the DBMain interface and define a few new methods. That's just fine. I would definitely not change the given interface.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
OCAJP 7
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2270
    
    3

Roel De Nijs wrote:I would definitely not change the given interface.


Me neither. And welcome to JavaRanch!


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 910
    
    3
Thanks,guys.

interface MyDBMain extends DBMain { //declare new method signatures....}
class Data extends MyDBMain { //implements MyDBMain, DBMain methods.....}

Sounds valid?

Roberto buddy wrote an example like that in his paper.Just make sure as English is my second langugage. Thanks for your patience.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 6354
    
  22

Himai Minh wrote:

interface MyDBMain extends DBMain { //declare new method signatures....}
class Data extends MyDBMain { //implements MyDBMain, DBMain methods.....}

Sounds valid?


That's a valid approach, but will not compile (classes don't extend interfaces)
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 910
    
    3

Correction:
class Data implements MyDBMain {...}
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: define new methods in DBMain