Question
absolute C++


QUESTION 1 Which statement is incorrect? When an event occurs that cannot be managed locally, an exception may be thrown. Thr
QUESTION 4 Which statement is incorrect? If an exception is to be caught, either the throw statement or a call to a function
QUESTION 7 The exception facility should NOT be used when A program requests a resource that is not available Some resource i
QUESTION 9 Which is incorrect? A programmer can use inheritance with an existing library for which only the header file and b
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

1)

Exceptions:

  • The abnormal functionality of an event in a program during execution raises to exception. So, the program throws the exception. If it is not handle by any of the method calls then the program abnormally terminates the program by either invoking the terminate() or abort() functions.

  • So, when a current function unable to handle the error then it propagates to previous function that is called from if that is also unable to handle, it goes to it next previous function call in which the error is handled.

  • In C++, exceptions can be defined either by user or by built in functions.

But, when an exception is raised and in unhandled by any of the function calls, then it can-not be ignored. The C++ indirectly invokes the terminate() or abort() functions.

Thus, the incorrect statement is: the 4’th option: An uncaught exception in C++ is ignored.

2)

  • An exception cannot be thrown outside the try catch block.

  • The function calls must be place in the try block and when the function throws the exception, then it will be handled by the catch block.

If this case, if the exception is thrown outside the try catch block, then the program terminates/abort abnormally.

Thus, the incorrect statement is: the 1’st option: Thrown outside a try block is incorrect.

4)

  • When a function is called from within the try..catch block, then the exception thrown by that function will be handled by the catch block.

  • So, the function that is called must be placed in the try block, and when the function throws an exception then it is caught and handled by the catch block.

  • If there are any statements in the program after the try..catch block, the those statements will be executed as well.

But, when an exception need to be caught, the throw statement must be either within the function say f() or within another function, say g() which is called by current function f(). But the called function g() cannot be present directly in the try..ctach.

Thus, the incorrect statement is: the 1’st option: If an exception is to be caught, either the statement or a call to a function that has the throw statement must be directly in a try block is incorrect.

7)

  • An exception is raised when the required source is not available or not possible to work with.

  • It can be used to handle when there is an array index out of bounds, and when there is abnormal execution encountered in the program.

But the exception is not used for resources which are unbailable to the compiler.

Thus, option 2: Some resource is unavailable to the compiler.

9)

  • When there is concept of inheritance, the programmer can use the exiting library by including the header files and the binary files to inherit and to be used in the derived class.

  • When B is a public base class of D, then the following are possible:

  • D’s members can invoke the private member functions of B with the help of inheritance.

  • D’s members can access the private data functions of B with the help of inheritance. This done by using the getter or setter methods to access the private data members.

If B is a public base class of D, then D’s members functions can invoke the public member functions of B directly.

Thus, the incorrect statement is: the 1’st option: If B is a public base class of D, then D’s members cannot invoke public member functions of B.

Add a comment
Know the answer?
Add Answer to:
absolute C++ QUESTION 1 Which statement is incorrect? When an event occurs that cannot be managed...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 1 (5 points) Question 1 Unsaved What is displayed on the console when running the...

    Question 1 (5 points) Question 1 Unsaved What is displayed on the console when running the following program? public class Quiz2B { public static void main(String[] args) { try { System.out.println("Welcome to Java"); int i = 0; int y = 2 / i; System.out.println("Welcome to Java"); } catch (RuntimeException ex) { System.out.println("Welcome to Java"); } finally { System.out.println("End of the block"); } } } Question 1 options: The program displays Welcome to Java two times. The program displays Welcome to...

  • QUESTION 1 If an exception is thrown None listed all listed execution terminates if there is...

    QUESTION 1 If an exception is thrown None listed all listed execution terminates if there is no catch block handling the same data type as the exception thrown execution continues if the catch block handles the same data type as the exception thrown 10 points    QUESTION 2 An exception is handled using an if-else statement an assignment statement a loop statement a try-catch block 10 points    QUESTION 3 In program 9.4, what is the data type being thrown?...

  • D Question 18 4 pts A function template is an actual function that the compiler uses...

    D Question 18 4 pts A function template is an actual function that the compiler uses to generate one or more functions. True False D Question 19 4 pts Calls to methods use the class identifier instead of the object identifier as the method qualifier. constructor friend static this Question 20 4 pts If inheritance is private, all members of the base class, including private members, become private members of the derived class. True False Question 21 4 pts is...

  • Question 10 (3 points) Which of the following statement is not true? There is a recursive...

    Question 10 (3 points) Which of the following statement is not true? There is a recursive sum method as shown below. When sum (19) is called, summation of all odd numbers less than 19 will be calculated and returned public int sum(int x){ if (x == 0) return 0: else return sum(x-2) + x; The following code segment will throw a testException. This exception has been handled in the way that do nothing but to continue when this exception happens....

  • Chapter 08 Python Assignment: Question 1-5 Please I need help in my python course. Question 1...

    Chapter 08 Python Assignment: Question 1-5 Please I need help in my python course. Question 1 The finally clause of a try statement a. can be used to recover from an exception b. is required c. can be used to display more information about an exception d. is executed whether or not an exception has been thrown 10 points Question 2 Which of the following is the correct way to code a try statement that catches any type of exception...

  • QUESTION 4 Which statement is incorrect? (1) Tatget population is the population about which we want...

    QUESTION 4 Which statement is incorrect? (1) Tatget population is the population about which we want to draw inferences (2) Self-sclected samples are not biased because individual who participate im them are more keenly interested in the issue than are the other members of the population (3) Sampled population is the actual population from which the sample has been taken (4) Selection bias occurs when the sampling plan is such that some members of the target population cannot possibly be...

  • Please provide the full code...the skeleton is down below: Note: Each file must contain an int...

    Please provide the full code...the skeleton is down below: Note: Each file must contain an int at the beginning, stating the number of records in the file. Afterwards, the number of records in the file will follow. Each record that follows will consist of a last name (String), and a gpa (double). However, to test the error handling of your program, the number of records will not always match the int value. All possible combinations should be tested. 1.) Prompt...

  • Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts...

    Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts What code is human-readable and follows the standards of a programming language? Secret code Source code Key code None of these Machine code Question 3 2 pts What is the symbol that marks the beginning of a one line comment? Question 1 2 pts The preprocessor executes after the compiler. True False Question 5 2 pts A statement that may be used to stop...

  • I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instruction...

    I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...

  • True False Question 2 (3 points) Given a singly linked list with more than two nodes,...

    True False Question 2 (3 points) Given a singly linked list with more than two nodes, to remove the second node from a linked list with only head reference, assume curr - head, next, you do Set curr.next to head.next Oset head. next to curr.next Set head, next to curr Oset head to curr.next TL th Question 3 (3 points) Given the following singly linked list (a list with four nodes), what will be the value stored at the last...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT