• Post Reply Bookmark Topic Watch Topic
  • New Topic

please clarify doubt in exceptions in core java  RSS feed

 
Malayathi Partha Saradhi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why we handle the method in sub class exception is subclas of superclass exception?
ex:
class A{
void method() throws Exception{
}
}
class B extends A{
void method()throws FileNotFoundException{
}
}

why in class B we handle subclass exception of super class exception.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exceptions tend to be related to where they occur. We handle the exception in sub class method by placing the method() in a try{}catch(FileNotFoundException e){} at the place where we call the class B method.

Class A appears to have not defined the method() tightly enough to determine FileNotFoundException as the cause of difficulty. Method in class B extends the capabilites of class A and can determine File Not Found may occur.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand the question correctly, it's an application of Liskov's Substitution Principle: a client of a class should be able to work with subclasses without knowing about it. A client that is used to handling *all* exceptions doesn't have a problem if a specific implementation only throws a specific subset of exceptions, so that's just fine.

Does that help?
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see where IDEs or version control or other tools apply to this question. Moving...
 
Adam Schaible
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please allow me to suggest some proper grammar. I used to just accept it as a language barrier - but we should not any more.

Your post is entitled "please clarify doubt in exceptions in core java". I'm not sure when Indian's decided to use the term "doubt" to describe their shortcomings but please, stop.


doubt �verb (used with object)
1. to be uncertain about; consider questionable or unlikely; hesitate to believe.
2. to distrust.
3. Archaic. to fear; be apprehensive about.


When you say you doubt something, you are saying you distrust the subject - in this case "exceptions in core java".

you should consider rephrasing your titles in the future - maybe something like "Please help me understand exceptions in core Java". I do not mean to crucify you for your lack of language understanding - but it seems cultural to use the term doubt incorrectly! This is an English forum, please learn the language.

Don't disrespect our language - use periods, capital letters, and complete sentences.
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Adam Schaible:
I'm not sure when Indian's decided to use the term "doubt" to describe their shortcomings...
The first citation the Oxford English Dictionary has for "doubt" in the sense of "A matter or point involved in uncertainty; a doubtful question; a difficulty" is 1347 by someone named Chaucer. I don't know when people in India adopted that obsolete usage, either, but it's far from wrong.

As for learning English, you might want to review the rules for formation of plurals as opposed to possessives yourself.
 
Adam Schaible
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how 1347 has any relevance to 2007(almost 8!). I also don't claim to be perfect with the language. I do expect people to represent their thoughts and questions in structures that don't require reading them several times and reverse-engineering their questions and context in an attempt to understand the meaning.


why we handle the method in sub class exception is subclas of superclass exception?


This is trash, don't accept it! My writing is definately is not the shining example to follow - but I don't lazily post malformed questions.

And my apologies for the apostrophe - I've always had trouble with that one!

I think it's a fair argument to say it's wrong. No one would argue that the world is indeed flat today, but it was considered an indisputable truth. When we are writing to explain ourselves, using an obsolete definition for a commonly used word is wrong! If the poster was a native English speaker, I would not be surprised to see someone blasting them for this, not using code tags, etc --

If it was someone from a different nationality, I would not be surprised to see them apologizing for their misuse of the language. Indians just seem to drop a deuce on it and not care.
[ December 03, 2007: Message edited by: Adam Schaible ]
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Adam Schaible:
I don't lazily post malformed questions.
I think it's possible that Malayathi does not speak English well. So I think classifying that ungrammatical question as "lazy" might be rather insulting. Wouldn't you agree?

What I'm trying to say here is that not everybody speaks the same English I do and not everybody speaks it well. I get irritated when I see people using the word "sorted" when I would say "solved", for example, but that's just a regional idiom. Asserting that there is only one way to speak English is going too far.
[ December 03, 2007: Message edited by: Paul Clapham ]
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've seen discussions of the use of 'doubt' before where it was suggested that it was used because it was a straight translation of the user's own language. I think it's pretty obvious what is meant and it's not really worth getting upset about.
As far as unintelligable posts are concerned - why not just ignore them. If you don't understand what is being asked, then don't bother to reply. It's the OP's loss, not yours. If they are being lazy, then they won't get any replies and maybe they will take a bit more time the next time they post. If, as is more likely, the problem is that English is not their first language, then that is unfortunate for them, but again not worth getting upset about.
 
Adam Schaible
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Clapham:
I think it's possible that Malayathi does not speak English well. So I think classifying that ungrammatical question as "lazy" might be rather insulting. Wouldn't you agree?


Absolutely not. He has used punctuation, so he is aware of the constructs in place to allow us to separate thoughts.

In the fragment: "why we handle the method in sub class exception is subclas of superclass exception?"

I'm not sure where the logical break is.
It could be:
why we handle the method in sub class? exception is subclas of superclass exception?
why we handle the method in sub class exception? is subclas of superclass exception?
why we handle the method? in sub class exception is subclas of superclass exception?

I have no idea what he means. It's ok if he's not familiar with exactly what punctuation to use - but it's lazy to not use any.

It's lazy to not explain your problem enough that others don't even know if they've answered it correctly - see Ilja Preuss's reply. The OP is getting something out of this, it's not wrong to ask him to make his questions readable.
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Adam Schaible:
The OP is getting something out of this, it's not wrong to ask him to make his questions readable.
Agreed. Asking for clarification, or saying the question is unclear, is normal behaviour. But accusations of laziness are getting a bit close to breaking this forum's main rule, which is "Be Nice". So I'd just like to ask you to ease up on that sort of thing.
 
Adam Schaible
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joanne Neal:
I've seen discussions of the use of 'doubt' before where it was suggested that it was used because it was a straight translation of the user's own langua....


As I stated originally, the other thousand times I've seen this I have ignored it. My point for this post is that we should expect a certain level of readability from people who ask for free help. I'm completely aware that I do not have to answer these posts - but as long as people answer them, there is no need to change.

This one is only 50% trash - there's some code posted to help us understand, and since the question is only one sentence long, there's a limited number of permutations for us to decipher.

To Paul:

I do agree with you - there is no single "absolutely correct" way to use the language. However, I don't think the OP's intent was to explore some of the more colorful ways to express herself. I just don't agree with the common double-standard.
[ December 03, 2007: Message edited by: Adam Schaible ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Adam]: He has used punctuation, so he is aware of the constructs in place to allow us to separate thoughts.

The fact that someone has used a question mark once does not imply mastery of how to use it (or other punctuation if that is more appropriate). Learning a foreign language typically requires a certain amount of trial and error. I think it's perfectly reasonable to say that the first post is too hard to understand, and request that the poster try to rephrase it more clearly. But I don't agree with assuming that this is caused by laziness or disrespect.
 
Malayathi Partha Saradhi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to all.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!