what is difference between throw and throws in exception?
Answer Posted / balu
throws clause is used when the programmer does not want to handle the exception and throw it out of a method.
throw clause is used when the programmer wants to throw an exception explicitly and wants to handle it using catch block hence throw and throws are contradictory.
throw clause can be used to throw our own exceptions also i.e user-defined exceptions.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is type safety in java?
What is the nested interface?
Can a variable be local and static at the same time?
What is binary tree in java?
What is default switch case? Give example.
What is the default access specifier for variables and methods of a class?
What is meant by object oriented programming – oop?
Is it necessary that each try block must be followed by a catch block?
What is immutability in java?
Which collection is best for sorting in java?
Why hashset is used in java?
Explain the protected field modifier?
What is vector?
What do you mean by constant time complexity?
Why we go for collections in java?