Prepare
Practice
Interview
Aptitude
Reasoning
English
GD
Placement papers
HR
Current affairs
Engineering
MCA
MBA
Online test
Login
Write throw clause inside catch handler - Exception Handling
Home
>>
Category
>>
C++ (MCQ) questions and answers
>>
Exception Handling
Q. Can we write throw clause inside catch handler?
- Published on 17 Jul 15
a.
Yes
b.
No
ANSWER: Yes
Related Content
Constructor and Destructor (
10
)
Operator Overloading (
11
)
Inheritance (
16
)
Polymorphism and Abstract Classes (
12
)
C++ basic concepts (
39
)
Exception Handling (
22
)
File Handling (
11
)
Functions (
20
)
Memory Management (
6
)
Pointers (
3
)
Discussion
Digvijay
-Posted on 24 Oct 15
Yes, we write throw clause inside catch handler.
Example:
void fun(int x)
{
try
{
if (x == 1)
throw 10;
}
catch (int x)
{
cout << "\n In Integer catch block";
throw 10;
}
catch (...)
{
cout << "\n\n in generic catch block";
}
}
int main()
{
int b = 1;
try
{
fun(b);
}
catch (char *e)
{
cout << e << endl;
}
catch (int x)
{
cout << "\n caught in int exception...\n\n";
}
return 0;
}
➨
Post your comment / Share knowledge
Required!
Required!
Invalid Email Id!
Required!
Enter the code shown above:
Please enter the code shown above
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)
MCQs
English
Tutorials
Download
▲