NTA-NET (UGC-NET) Computer Science & Applications (87) Programming in C and C Plus Plus-C Plus Plus Programming Study Material (Page 13 of 54)
Choose Programs:
⏳ 🎯 Online Tests (4 Tests [100 questions each]): NTA Pattern, Analytics & Explanations
Rs. 800.00 -OR-
3 Year Validity (Multiple Devices)
Sample TestsDetailsSee Demo
🎓 Study Material (2083 Notes): 2024-2025 Syllabus
Rs. 1250.00 -OR-
3 Year Validity (Multiple Devices)
Topic-wise Notes & SampleDetails
🎯 2699 MCQs (& PYQs) with Full Explanations (2024-2025 Exam)
Rs. 600.00 -OR-
3 Year Validity (Multiple Devices)
CoverageDetailsSample Explanation
Help me Choose & Register (Watch Video) Already Subscribed?
Throwing and Catching Exceptions
Throwing Exceptions
The throw statements can be used to throw exceptions anywhere within a block of code. The operand of the throw statements tries to decide a type for the exception and can be any expression and the type of the result of the expression decides the type of exception thrown.
Example: Throwing an exception when dividing by zero condition arises:
double divisionofnumbers ( int num, int den )
{
If ( den==0 )
{
throw “ Division by zero is not allowed ! ; ”
}
return ( num/den ) ;
}
Catching Exceptions
In general, the catch block that is followed by the try block tries to catches any exception. It is possible to specify what type of exception that is to be …
… (189 more words) …
Subscribe (by clicking here) to view full notes and track progress.
Catch All Exceptions, Rethrowing, Specifying, Standard and Define New Exceptions
Catch All Exceptions
In some situations, when all possible type of exceptions cannot be predicted and may not be able to determine independent catch handlers to catch them, in such situations a single catch statement is enforced to catch all exceptions instead of specific type alone. This can be accomplished by defining the catch statement by using ellipses (…) . In general, it is possible to use the catch (…) statement as a default statement along with other catch handlers,…
… (359 more words) …
Subscribe (by clicking here) to view full notes and track progress.