what is difference between throw and throws in exception?
Answer Posted / arun
throw is used to throw an exception manually when we feel
that particular line of code in our program is going to
throw an exception
throw new MyException("exception")
throws is used instead of try and catch block,if we are not
using try and catch block and we know that our program is
going to throw an exception than we use throws key word
public void myExecption() throws Exception
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the program compilation process?
Why java is not 100% object-oriented?
What is bom encoding?
What data type is true or false?
How can you avoid serialization in child class if the base class is implementing the serializable interface?
Which is the class in java?
What’s the difference between callable and runnable?
Is empty string in java?
What do you mean by scope of variable?
What is covariant return type?
What is the differences between heap and stack memory in java? Explain
What is a null check?
What is the function of log?
What is difference between filereader and bufferedreader?
what is singleton class in java?