LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C++ Programming
  • Error Handling Alternatives

C++ Programming

ERROR HANDLING ALTERNATIVES MCQs

Total Questions : 10

Question 1.

What will happen when an exception is not processed?


  1.    It will eat up lot of memory and program size
  2.    Terminate the program
  3.    Crash the compiler
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> It will eat up lot of memory and program size

As in the case of not using an exception, it will remain useless in the program and increase 

the code complexity.

Question 2.

Pick out the correct statement for error handling alternatives.


  1.    Terminate the program
  2.    Use the stack
  3.    exit from the block
  4.    none of the mentioned
 Discuss Question
Answer is Option B. -> Use the stack

When an error is arised means, it will be pushed into stack and it can be corrected later by 

the programmer.

Question 3.

How many levels are there in exception safety?


  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer is Option C. -> 3

The three levels of exception safety are basic, strong and nothrow.

Question 4.

What is the use of RAII in c++ programing?


  1.    Improve the exception safety
  2.    Terminate the program
  3.    Exit from the block
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> Improve the exception safety

None.

Question 5.


What is the output of this program?



1.
#include
2.
#include
3.
#include
4.
using namespace std;
5.
void MyFunc(char c)
6.
{
7.
if (c < numeric_limits::max())
8.
return invalid_argument;
9.
}
10.
int main()
11.
{
12.
try
13.
{
14.
MyFunc(256);
15.
}
16.
catch(invalid_argument& e)
17.
{
18.
cerr
  1.    256
  2.    invalid argument
  3.    Error
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> Error

We can't return a statement by using the return keyword, So it is arising an error.

Question 6.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
void Division(const double a, const double b);
4.
int main()
5.
{
6.
double op1=0, op2=10;
7.
try
8.
{
9.
Division(op1, op2);
10.
}
11.
catch (const char* Str)
12.
{
13.
cout << "n\Bad Operator: " << Str;
14.
}
15.
return 0;
16.
}
17.
void Division(const double a, const double b)
18.
{
19.
double res;
20.
if (b == 0)
21.
throw "Division by zero not allowed";
22.
res = a / b;
23.
cout << res;
24.
}


  1.    0
  2.    Bad operator
  3.    10
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> 0

We are dividing 0 and 10 in this program and we are using the throw statement in the function block.
Output:
$ g++ eal.cpp
$ a.out
0

Question 7.

What is most suitable for returning the logical errors in the program?


  1.    Use contructor and destructor
  2.    Set a global error indicator
  3.    Use break keyword
  4.    none of the mentioned
 Discuss Question
Answer is Option B. -> Set a global error indicator

None.

Question 8.


What is the output of this program?



1.
#include
2.
#include
3.
using namespace std;
4.
class A
5.
{
6.
};
7.
int main()
8.
{
9.
char c; float x;
10.
if (typeid(c) != typeid(x))
11.
cout
  1.    0
  2.    Bad operator
  3.    10
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> 0

Answer:a
Explanation:
We are checking the type id of char and float as they are not equal, We are printing c.
Output:
$ g++ eal.cpp
$ a.out
c
1A

Question 9.

What are the disadvantages if use return keyword to return error codes?


  1.    You have to handle all exceptional cases explicitly
  2.    Your code size increases dramatically
  3.    The code becomes more difficult to read
  4.    All of the mentioned
 Discuss Question
Answer is Option D. -> All of the mentioned

As we are using return for each and every exception, It will definetly increase the code size.

Question 10.

Which alternative can replace the throw statement?


  1.    for
  2.    break
  3.    return
  4.    exit
 Discuss Question
Answer is Option C. -> return

throw and return does the same job like return a value. So it can be replaced.

  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

  • Abstract Classes
  • Access Control
  • Argument Passing
  • Arrays
  • Booleans
  • C++ Concepts
  • Catching Exceptions
  • Character Types
  • Class Hierarchies And Abstract Classes
  • Class Hierarchies Introduction
  • Classes
  • Comments And Indentation
  • Complex Number Type
  • Constants
  • Constructors And Destructors
  • Container Design
  • Conversion Operators
  • Declaration
  • Default Arguments
  • Dereferencing
  • Derivation And Templates
  • Derived Classes
  • Design Of Class Hierarchies
  • Enumerations
  • Error Handling
  • Error Handling Alternatives
  • Essential Operators
  • Exception Specifications
  • Exceptions
  • Exceptions And Efficiency
  • Exceptions That Are Not Errors
  • Floating Point Types
  • Free Store
  • Friends
  • Function Call
  • Function Declarations
  • Function Templates
  • Functions
  • Grouping Of Exceptions
  • Header Files Usage
  • Increment And Decrement
  • Integer Types
  • Large Objects
  • Linkage
  • Macros
  • Modularization And Interfaces
  • Multiple Inheritance
  • Namespaces
  • Objects
  • Objects And Classes
  • Oops Concepts
  • Operator Functions
  • Operators
  • Overloaded Function Names
  • Pointer To Function
  • Pointer To Void
  • Pointers
  • Pointers Into Arrays
  • Pointers To Members
  • References
  • Resource Management
  • Run Time Type Information
  • Sequence Adapters
  • Sequences
  • Simple String Template
  • Sizes
  • Specialization
  • Standard Exceptions
  • Standard Library Design
  • Statements
  • String Class
  • Structures
  • Subscripting
  • Template Arguments To Specify Policy Usage
  • Types
  • Uncaught Exceptions
  • Unspecified Number Of Arguments
  • User Defined Types
  • Value Return
  • Vector
  • Void

Topics

  • Computer Aptitude
  • SAIL Junior Officer (E-0)
  • 10th Grade
  • 11th Grade
  • 12th Grade
  • 4th Grade
  • 5th Grade
  • 6th Grade
  • 7th Grade
  • 8th Grade
  • 9th Grade
  • NCERT
  • Cat
  • Commerce
  • Computer Science
  • Engineering
  • English
  • General Knowledge
  • Ias
  • Management
  • Quantitative Aptitude
  • Reasoning Aptitude
  • General Studies (Finance And Economics)
  • Analytical Instrumentation
  • Biochemistry
  • Bioinformatics
  • Biology
  • Biotechnology
  • Bitsat
  • Business Statistics
  • C Programming
  • C++ Programming
  • Cell Biology
  • Chemistry
  • Cost Accounting
  • Drug And Pharmaceutical Biotechnology
  • Electrical Measurement And Instrumentation
  • Environment Management
  • Environmental Biotechnology
  • Enzyme Technology
  • Financial Management And Financial Markets
  • Gate
  • General Science
  • Geography
  • Heat Transfer
  • History And National Movements
  • Human Anatomy And Physiology
  • Human And Cultural Diversity
  • Human Resource Management
  • Indian Economy
  • Indian Geography
  • Indian History
  • Indian Polity
  • Instrumentation Transducers
  • International Relations
  • Life Sciences
  • Marketing And Marketing Management
  • Mass Transfer
  • Mechanics Of Materials
  • Microbiology
  • Neet
  • Professional Communication
  • Renewable Energy
  • Sociology
  • Surveying
  • Total Quality Management
  • Uidai Aadhaar Supervisor Certification
  • Virology

Recent Questions

Q.   DIVA:OPERA

Q.   All Computers Must Have __________

Q.   Which Of The Following Statements Are Correct With Regard To....

Q.   (solve As Per The Direction Given Above)

Q.   Deficiency Of 'Thiamine' Causes

Q.   In Each Question Below A Sentence Broken Into Four Or Five P....

Q.   IRS 1A And 1B Satellites Can Carry Which Of The Following Se....

Q.   ....

Q.   For A Dc Machine Shunt Resistance And Armature Resistance Va....

Q.   ....

Q.   Who Among The Following Was The First English Man To Visit W....

Q.   Find The Correctly Spelt Word

Q.   The Color Of Fluorine Is

Q.   Rashi Went  toy Shopping With Her Mother And Saw A Toy ....

Q.   The Process Partially Responsible For The Life On Earth Is

Q.   What Is The Place Of The Indian Men's Cricket Team In The La....

Q.   ....

Q.   Match The Following: 1. Nishka (i) Later Vedic Coi....

Q.   Which Fertiliser Is Made (using Coke Oven Gas) In By Product....

Q.   ....

LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • YouTube Channel
  • Maths Fast Trick
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password