• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception thrown  RSS feed

 
Santosh Kumar Nayak
Ranch Hand
Posts: 193
Eclipse IDE IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 classes. Class A and Class B under same package.

In case there is an Exception thrown from Class B. Can it be handled by Class A ?

There are not parent or child classes > Both are different classes.

 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post some example code?

Exceptions are handled inside methods not classes.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, classes don't throw exceptions. An exception can be thrown from a method.

And ofcourse, if a method in class B throws an exception, then a method in class A which calls that method in class B can catch that exception. It would be pretty strange if that wasn't possible.
 
Santosh Kumar Nayak
Ranch Hand
Posts: 193
Eclipse IDE IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!