SlideShare una empresa de Scribd logo
1 de 5
Descargar para leer sin conexión
www.fellowbuddy.com
Simplifying Students Life
Exception Handling
1. An exception is thrown using _____________ keyword in CPP.
a. throws
b. throw
c. threw
d. thrown
2. The code of statements which may cause abnormal termination of the program should be
written under_________ block
a. try
b. catch
c. Finally
d. None of these
3. Exception handlers are declared with ____________ keyword
a. Try
b. catch
c. throw
d. finally
4. Catch handler can have multiple parameters.
a. True
b. False
5. Which of the following statements are true about Catch handler ?
1. It must be placed immediately after try block T
2. It can have multiple parameters
3. There must be only one catch handler for every try block
4. There can be multiple catch handler for a try block T
5. Generic catch handler can be placed anywhere after try block.
a. Only 1, 4, 5
b. Only 1, 2, 3
c. Only 1, 4
d. Only 1, 2
www.fellowbuddy.com
Simplifying Students Life
6. A try block can be nested under another try block –
a. Yes
b. No
7. In nested try blocks, there is no need to specify catch handler for inner try block. Outer catch
handler is sufficient for the program.
a. True
b. False
8. In nested try block, if inner catch handler gets executed, then______________
a. Program execution stops immediately
b. Outer catch handler will also get executed
c. Compiler will jump to the outer catch handler and then executes remaining executable
statements of main()
d. Compiler will execute remaining executable statements of outer try block and then the main()
9. If inner catch handler is not able to handle the exception then__________
a. Compiler will look for outer try handler
b. Program terminates abnormally
c. Compiler will check for appropriate catch handler of outer try block
d. None of these
10. Generic catch handler must be placed at the end of all the catch handlers
a. True
b. False
11. Generic catch handler is represented by ______________
a. catch(..,)
b. catch(---)
c. catch(…)
d. catch( void x)
12. In nested try blocks, if both inner and outer catch handlers are not able to handle the
exception, then______________
www.fellowbuddy.com
Simplifying Students Life
a. Compiler executes only executable statements of main()
b. Compiler issues compile time errors about it
c. Program will be executed without any interrupt
d. Program will be terminated abnormally
13. Functions called from within a try block may also throw exception
a. True
b. False
14. Irrespective of exception occurrence, catch handler will always get executed.
a. True
b. False
15. Throwing an unhandled exception causes standard library function _______________ to be
invoked.
a. stop()
b. aborted()
c. terminate()
d. abandon()
16. An exception can be of only built-In type.
a. True
b. False
17. We can prevent a function from throwing any exceptions.
a. True
b. False
18. How can we restrict a function to throw certain exceptions?
a. Defining multiple try and catch block inside a function
b. Defining generic function within try block
c. Defining function with throw clause
d. It is not possible in CPP to restrict a function
www.fellowbuddy.com
Simplifying Students Life
19. Attempting to throw an exception that is not supported by a function call results in calling
_____________ library function.
a. indeterminate()
b. unutilized()
c. unexpected()
d. unpredicted()
20. Return type of uncaught_exception() is________________
a. int
b. bool
c. char *
d. double
21. Can we write throw clause inside catch handler?
a. Yes
b. No
22. Can we define our exceptions in CPP?
a. Yes
b. No
Answers
1. ANSWER: b. throw
2. ANSWER: a. try
3. ANSWER: b. catch
4. ANSWER: b. False
Explanation: A catch handler should contain only one parameter of any type.
Multiple parameters are not allowed inside catch handler.
5. ANSWER: c. Only 1, 4
6. ANSWER: a. Yes
7. ANSWER: b. False
Explanation: For every try block, there must be at least one catch hander.
Otherwise, compiler will generate error.
8. ANSWER: d. Compiler will execute remaining executable statements of outer try block and
then the main()
9. ANSWER: c. Compiler will check for appropriate catch handler of outer try block
www.fellowbuddy.com
Simplifying Students Life
10. ANSWER: a. True
11. ANSWER: c. catch(…)
12. ANSWER: d. Program will be terminated abnormally
13. ANSWER: a. True
14. ANSWER: b. False
Explanation: catch handler will only get execute when exception occurs at runtime
15. ANSWER: c. terminate()
16. ANSWER: b. False
Explanation:: An exception can be of any type, including class type that we create.
17. ANSWER: a. True
18. ANSWER: c. Defining function with throw clause
19. ANSWER: c. unexpected()
20. ANSWER: b. bool
21. ANSWER: a. Yes
Explanation: In case of re-throwing an exception, we can use throw clause in a catch
handler.
22. ANSWER: a. Yes
Explanation : We can define our own exception by inheriting and overriding
exception class functionality.

Más contenido relacionado

Más de FellowBuddy.com

Más de FellowBuddy.com (20)

The Internet, Intranet and Extranet
The Internet, Intranet and ExtranetThe Internet, Intranet and Extranet
The Internet, Intranet and Extranet
 
Database Management System
Database Management System Database Management System
Database Management System
 
Operating System
Operating System Operating System
Operating System
 
Microsoft Office PowerPoint 2007 Training
Microsoft Office PowerPoint 2007 TrainingMicrosoft Office PowerPoint 2007 Training
Microsoft Office PowerPoint 2007 Training
 
Social science class_x
Social science class_xSocial science class_x
Social science class_x
 
Maths class x
Maths class xMaths class x
Maths class x
 
Business Studies Class xii
Business Studies Class xiiBusiness Studies Class xii
Business Studies Class xii
 
Risk and Risk Aversion FM
Risk and Risk Aversion FMRisk and Risk Aversion FM
Risk and Risk Aversion FM
 
Refrigeration Engineering Lecture Notes
Refrigeration Engineering Lecture NotesRefrigeration Engineering Lecture Notes
Refrigeration Engineering Lecture Notes
 
Production and Operation Management Lecture Notes
Production and Operation Management Lecture NotesProduction and Operation Management Lecture Notes
Production and Operation Management Lecture Notes
 
Strategic HRM {HR}
Strategic HRM {HR}Strategic HRM {HR}
Strategic HRM {HR}
 
Leadership Theories {HR}
Leadership Theories {HR}Leadership Theories {HR}
Leadership Theories {HR}
 
Interpersonal Communication Skills {HR}
Interpersonal Communication Skills {HR}Interpersonal Communication Skills {HR}
Interpersonal Communication Skills {HR}
 
Industrial Dispute Act, 1947 {HR}
Industrial Dispute Act, 1947 {HR}Industrial Dispute Act, 1947 {HR}
Industrial Dispute Act, 1947 {HR}
 
Factories act, 1948 {HR}
Factories act, 1948 {HR}Factories act, 1948 {HR}
Factories act, 1948 {HR}
 
Ratio and Proportion, Indices and Logarithm Part 4
Ratio and Proportion, Indices and Logarithm Part 4Ratio and Proportion, Indices and Logarithm Part 4
Ratio and Proportion, Indices and Logarithm Part 4
 
Ratio and Proportion, Indices and Logarithm Part 2
Ratio and Proportion, Indices and Logarithm Part 2Ratio and Proportion, Indices and Logarithm Part 2
Ratio and Proportion, Indices and Logarithm Part 2
 
Ratio and Proportion, Indices and Logarithm Part 1
Ratio and Proportion, Indices and Logarithm Part 1Ratio and Proportion, Indices and Logarithm Part 1
Ratio and Proportion, Indices and Logarithm Part 1
 
Limits and Continuity - Intuitive Approach part 3
Limits and Continuity - Intuitive Approach part 3Limits and Continuity - Intuitive Approach part 3
Limits and Continuity - Intuitive Approach part 3
 
Limits and Continuity - Intuitive Approach part 2
Limits and Continuity - Intuitive Approach part 2Limits and Continuity - Intuitive Approach part 2
Limits and Continuity - Intuitive Approach part 2
 

Último

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Exception handling www.fellowbuddy.com

  • 1. www.fellowbuddy.com Simplifying Students Life Exception Handling 1. An exception is thrown using _____________ keyword in CPP. a. throws b. throw c. threw d. thrown 2. The code of statements which may cause abnormal termination of the program should be written under_________ block a. try b. catch c. Finally d. None of these 3. Exception handlers are declared with ____________ keyword a. Try b. catch c. throw d. finally 4. Catch handler can have multiple parameters. a. True b. False 5. Which of the following statements are true about Catch handler ? 1. It must be placed immediately after try block T 2. It can have multiple parameters 3. There must be only one catch handler for every try block 4. There can be multiple catch handler for a try block T 5. Generic catch handler can be placed anywhere after try block. a. Only 1, 4, 5 b. Only 1, 2, 3 c. Only 1, 4 d. Only 1, 2
  • 2. www.fellowbuddy.com Simplifying Students Life 6. A try block can be nested under another try block – a. Yes b. No 7. In nested try blocks, there is no need to specify catch handler for inner try block. Outer catch handler is sufficient for the program. a. True b. False 8. In nested try block, if inner catch handler gets executed, then______________ a. Program execution stops immediately b. Outer catch handler will also get executed c. Compiler will jump to the outer catch handler and then executes remaining executable statements of main() d. Compiler will execute remaining executable statements of outer try block and then the main() 9. If inner catch handler is not able to handle the exception then__________ a. Compiler will look for outer try handler b. Program terminates abnormally c. Compiler will check for appropriate catch handler of outer try block d. None of these 10. Generic catch handler must be placed at the end of all the catch handlers a. True b. False 11. Generic catch handler is represented by ______________ a. catch(..,) b. catch(---) c. catch(…) d. catch( void x) 12. In nested try blocks, if both inner and outer catch handlers are not able to handle the exception, then______________
  • 3. www.fellowbuddy.com Simplifying Students Life a. Compiler executes only executable statements of main() b. Compiler issues compile time errors about it c. Program will be executed without any interrupt d. Program will be terminated abnormally 13. Functions called from within a try block may also throw exception a. True b. False 14. Irrespective of exception occurrence, catch handler will always get executed. a. True b. False 15. Throwing an unhandled exception causes standard library function _______________ to be invoked. a. stop() b. aborted() c. terminate() d. abandon() 16. An exception can be of only built-In type. a. True b. False 17. We can prevent a function from throwing any exceptions. a. True b. False 18. How can we restrict a function to throw certain exceptions? a. Defining multiple try and catch block inside a function b. Defining generic function within try block c. Defining function with throw clause d. It is not possible in CPP to restrict a function
  • 4. www.fellowbuddy.com Simplifying Students Life 19. Attempting to throw an exception that is not supported by a function call results in calling _____________ library function. a. indeterminate() b. unutilized() c. unexpected() d. unpredicted() 20. Return type of uncaught_exception() is________________ a. int b. bool c. char * d. double 21. Can we write throw clause inside catch handler? a. Yes b. No 22. Can we define our exceptions in CPP? a. Yes b. No Answers 1. ANSWER: b. throw 2. ANSWER: a. try 3. ANSWER: b. catch 4. ANSWER: b. False Explanation: A catch handler should contain only one parameter of any type. Multiple parameters are not allowed inside catch handler. 5. ANSWER: c. Only 1, 4 6. ANSWER: a. Yes 7. ANSWER: b. False Explanation: For every try block, there must be at least one catch hander. Otherwise, compiler will generate error. 8. ANSWER: d. Compiler will execute remaining executable statements of outer try block and then the main() 9. ANSWER: c. Compiler will check for appropriate catch handler of outer try block
  • 5. www.fellowbuddy.com Simplifying Students Life 10. ANSWER: a. True 11. ANSWER: c. catch(…) 12. ANSWER: d. Program will be terminated abnormally 13. ANSWER: a. True 14. ANSWER: b. False Explanation: catch handler will only get execute when exception occurs at runtime 15. ANSWER: c. terminate() 16. ANSWER: b. False Explanation:: An exception can be of any type, including class type that we create. 17. ANSWER: a. True 18. ANSWER: c. Defining function with throw clause 19. ANSWER: c. unexpected() 20. ANSWER: b. bool 21. ANSWER: a. Yes Explanation: In case of re-throwing an exception, we can use throw clause in a catch handler. 22. ANSWER: a. Yes Explanation : We can define our own exception by inheriting and overriding exception class functionality.