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
When will we prefer to use set and list in java and why?
How do you convert bytes to character in java?
Why are the methods of the math class static?
What are JVM.JRE, J2EE, JNI?
Is vector synchronized in java?
What is constructor in java ?
List some features of the abstract class.
What is treeset in java?
What is a java developer salary?
How do you check whether the list is empty or not in java?
Describe 2 different ways to concatenate two strings.
What is the difference between a switch statement and an if statement?
What are packages in java?
Can we use different return types for methods when overridden?
How many static init can you have?