• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCJD book: Implementing two Interfaces

 
Michael Enudi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day all,

I am particularly new to this site and want to ask a question that really bothers me.

In the book "SCJD Exam with J2SE" by Andrew Monkhouse and Terry Camerlengo, I find something very worrying.


In the book, the author created a class DBClient and another DvdDatabaseRemote which is basically a remote extension of the DBClient interface. The code has it thus


What surprises me is that the implementation of the class which is


has some of its method throwing RemoteException whereas the declaring methods don't. How possible is that, knowing that in java you cannot throw a newer Exception while overriding a method?

Secondly, how is it possible for remote object to publish its remote method without throwing the RemoteException?

I find these two issues with the book but I don't know If I am the one seeing things rather blurred.
I would appreciate clarification.


Regards.
 
Marcel van den Boer
Greenhorn
Posts: 21
Java Linux Notepad
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RemoteException is-a IOException, and IOException is declared in DBClient.

An other example:
 
Roel De Nijs
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I have a look at the methods in DBClient, I see that all methods have a throws IOException clause, e.g.

And if you would have made the effort to take a look at the javadoc of RemoteException, you would have noticed that IOException is its parent class, so completely valid overrides.

[edit] Marcel was a lot quicker (even after refreshing the page, I didn't see his reply)
 
Michael Enudi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys, I did not know what I was looking at. Assumption led me astray.

Thanks for the pointer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic