Cognizant Tech Solutions Interview Question
171 Interview Reviews |
Back to all Cognizant Tech Solutions Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Web Developer at Cognizant Tech Solutions:
Q: what are exception in java, what are their types?
See more for this Cognizant Tech Solutions Web Developer Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (1)
Members can
answer or comment on this question
–
Join Now (It's Free) or
Sign In
0 of 0 people found this helpful
by Interview Candidate:
Runtime Exceptions (unchecked exception) A RuntimeException class represents exceptions that occur within the Java virtual machine (during runtime). An example of a runtime exception is NullPointerException. The cost of checking for the runtime exception often outweighs the benefit of catching it. Attempting to catch or specify all of them all the time would make your code unreadable and unmaintainable. The compiler allows runtime exceptions to go uncaught and unspecified. If you Java like, you can catch these exceptions just like other exceptions. However, you do not have to declare it in your “throws" clause or catch it in your catch clause. In addition, you can create your own RuntimeException subclasses and this approach is probably preferred at times because checked exceptions can complicate method signatures and can be difficult to follow.