Aman Kulkarni wrote:
Stephan van Hulst wrote:If you did that, what should it mean?
I haven't tried it yet due to some java unavailability...I am for holidays and the only thing I have is the internet connection...So thought of asking it !
Henry Wong wrote:
Aman Kulkarni wrote:
Stephan van Hulst wrote:If you did that, what should it mean?
I haven't tried it yet due to some java unavailability...I am for holidays and the only thing I have is the internet connection...So thought of asking it !
You don't need availability to java to answer the question. Let's assume that it was allowed, what would you expect it to do... After all, you asked why we can't use a feature? You should have an idea of what this feature will do right?
Henry
Stephan van Hulst wrote:That seems non-intuitive. Throwing and handling exceptions are polar opposites. When you use the throws keyword on a method signature, it doesn't mean the method handles the exception. It means it may throw that exception under certain circumstances, and code calling the method should deal with the possibility that that particular exception may be thrown.
It doesn't make sense on the class level. So no, you can't do this.
Chandraprakash Sarathe
http://javaved.blogspot.com
Aman Kulkarni wrote:
Henry Wong wrote:
Aman Kulkarni wrote:
Stephan van Hulst wrote:If you did that, what should it mean?
I haven't tried it yet due to some java unavailability...I am for holidays and the only thing I have is the internet connection...So thought of asking it !
You don't need availability to java to answer the question. Let's assume that it was allowed, what would you expect it to do... After all, you asked why we can't use a feature? You should have an idea of what this feature will do right?
Henry
If we use it in the class itself...All the exceptions of the entire class will be handled.
...I am asking is it allowed ??
Aman Kulkarni wrote:
Stephan van Hulst wrote:If you did that, what should it mean?
I haven't tried it yet due to some java unavailability...I am for holidays and the only thing I have is the internet connection!
Chandraprakash Sarathe wrote:No question is silly question.
In Object Oriented Paradigm Class provides template and object act as implementation to these templates in the form of methods , instance variables.
Java provides "throws Exception" at Object level i.e in constructor as well as in methods.
So it makes sense to have throws clause at method level rather than class level.