Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception

 
adam Lui
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"if the overridden method does not throw any exception, the overriding method cannot throw any checked exception, but it can still throw a runtime exception"

does it mean...

class A {
void methodA {}
}
class B extends A{
void methodA throws ArrayIndexOutOfBoundsException, ClassCastException {}
}

is legal??
 
Yogesh Baraskar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

This is perfectly legal.
You can declare any runtime exceptions
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic