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....

  • 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...

  • 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...

  • !!!!!!!Java!!!!! When you are confident that your methods work properly and that you can generate random...

    !!!!!!!Java!!!!! When you are confident that your methods work properly and that you can generate random text with my generateText method, you can move on to the second step. Create a third class called Generator within the cs1410 package. Make class. This class should have a main method that provides a user interface for random text generation. Your interface should work as follows: Main should bring up an input dialog with which the user can enter the desired analysis level...

  • C++ Inheritance Problem Step a: Suppose you are creating a fantasy role-playing game. In this game...

    C++ Inheritance Problem Step a: Suppose you are creating a fantasy role-playing game. In this game we have four different types of Creatures: Humans, Cyberdemons, Balrogs, and elves. To represent one of these Creatures we might define a Creature class as follows: class Creature { private: int type; // 0 Human, 1 Cyberdemon, 2 Balrog, 3 elf int strength; // how much damage this Creature inflicts int hitpoints; // how much damage this Creature can sustain string getSpecies() const; //...

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