File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes exceptions = member classes ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "exceptions = member classes ?" Watch "exceptions = member classes ?" New topic
Author

exceptions = member classes ?

Andy Jung
Ranch Hand

Joined: Feb 07, 2010
Posts: 150
Hi all,

The assignment says:
Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package.


"Java in a Nutshell" defines member classes this way:
A member class is a class that is declared as a non-static member of a containing class.


I just placed those exceptions (RecordNotFoundException, DuplicateKeyException, SecurityException) in package suncertify.db,
without making them inner classes to any containing class.

Did I violate this requirement ?

Kind regards,
Andy


SCJP, SCJD
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5596
    
  15

Your exception classes should just be classes inside the db-package, not as inner classes of the Data class.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Roel De Nijs wrote:Your exception classes should just be classes inside the db-package, not as inner classes of the Data class.


Agreed. And do not forget the constructors specified in the assignment!


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

Joined: Feb 07, 2010
Posts: 150
... ok, that's fine, I submitted the project yesterday anyways ...
Matheus Mendes
Ranch Hand

Joined: May 15, 2007
Posts: 66
The spec says:
" ... member classes of the suncertify.db package..."
. Just put inside the package and it's alright.

Good lucky and keep on touch to let us know the positive result.

The Death of one is a tragedy, but the Death of a million is just a statistic. Joseph Stalin

SCJP 6.0, SCJD
David Kachen
Ranch Hand

Joined: May 20, 2010
Posts: 42
Hi All,

I do not think that the use of javax.ejb.DuplicateKeyException - is good. I think that we should make a new Exception.

I did as follows:
SecurityException already exists (in java.lang). RecordNotFoundException and DuplicateKeyException I have extends from java.lang.IllegalArgumentException.

A javax.ejb.DuplicateKeyException designed specifically for the EJB.

Best Regards..
David Kachen
Ranch Hand

Joined: May 20, 2010
Posts: 42
I guess I was a little mistaken. I'm new at this forum, please forgive me if I'm wrong. In the first message I passed on the link and got to DuplicateKeyException javax.ejb.DuplicateKeyException. I thought that the developer decided not to create a DuplicateKeyException and instead use javax.ejb.DuplicateKeyException.
And as it turned out, the editor himself makes reference to the message.

Best Regards
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5596
    
  15

David Kachen wrote:I did as follows:
SecurityException already exists (in java.lang).

Javadoc of the SecurityException says:
Thrown by the security manager to indicate a security violation.
So i think you should create your own SecurityException instead of reusing this one (because your code will throw the exception and not a security manager)

Kind regards,
Roel
David Kachen
Ranch Hand

Joined: May 20, 2010
Posts: 42
Thanks Roel, I think that you are right.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exceptions = member classes ?