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 a vararg?
What is the covariant return type?
How do generics work in java?
Are arrays primitive data types?
Are arrays immutable in java?
What is stream api in java8?
What is the disadvantage of java?
Is vector ordered in java?
Is array dynamic in java?
What is the difference between a break statement and a continue statement?
What are accessor methods in java?
What are the steps involved to create a bean?
Explain the advantages of packages in java?
What is static keyword?
What is the current version of java?