This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception handling an Polymorphism

 
Thomas Markl
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is wrong about this program?
Thank you for answers.
Thomas

> cd C:\jdk1.3\bin
> javac Fredtest1.java

[Edited to preserve formatting -DS]
[ June 10, 2002: Message edited by: Dirk Schreckmann ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thomas Markl:
What is wrong about this program?
[...]


I think youself gave the answer: fred() in base does not throw SomeOtherException, therefore fred() in derived is not allowed to.
 
Andrew Spruce
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you could either :
1) Add throws FredException to fred() in derived.
2) Have SomeOtherException extend FredException.
e.g.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic