PICK AN OPTION: 1) Given the following function defintion, what happens if the f
ID: 3843388 • Letter: P
Question
PICK AN OPTION:
1) Given the following function defintion, what happens if the function throws the exception?
void f1() throw(double)
{
if( //some code here)
throw 12;
}
a. the 12 will be converted to 12.0
b. the function will throw an integer exeption which is passed to the calling code.
c. the function will cause the program to exit
d. the code has a syntax error
2) If class A is derived from class B. and a virtual function in class B throws an exception, then the overridden version of that function in class A must
a. not throw any exceptions
b. have an exception specification that is a subset of the exception specification of the base class B
c. not throw any exceptions that the function in class B might throw
d. all the above
3) A class that is used for exceptions is declared
a. differently from other classes
b. specialized only for exceptions
c. may not have objects declared of that class
d. all the above
e. none of the above
4) Which of the following code fragments are illega?
a. try
{
try
{
//other code here
}
catch(int e)
{
//code here
}
}
catch(float e)
{
//code here
}
b. try
{
//code here
}
catch(int e)
{
//code here
try
{
//code here
}
catch(string e)
{
}
}
c. all of the above
d. none of the above
Explanation / Answer
Question1:
1) Given the following function defintion, what happens if the function throws the exception?
void f1() throw(double)
{
if( //some code here)
throw 12;
}
Answer:
a)the 12 will be converted to 12.0
2) If class A is derived from class B. and a virtual function in class B throws an exception, then the overridden version of that function in class A must
Answer:
c. not throw any exceptions that the function in class B might throw
3.A class that is used for exceptions is declared
Answer:
d.none of the above
e.none of the above
4) Which of the following code fragments are illegal?
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.