This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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