Question

In: Computer Science

(T or F)   C++ throws an exception if you try to refer to element 47 in...

  1. (T or F)   C++ throws an exception if you try to refer to element 47 in an array with 20 elements.
  2. (T or F)   I can copy one array to another by simply using an assignment statement which assigns the one array to the other.
  3. (T or F) An exception is the occurrence of an erroneous or unexpected situation during the execution of a program.
  4. (T or F) The try / catch structure is used to test for and catch occurrences of syntax errors.
  5. (T or F) There can be no code between a try-block and its associated catch-block.
  6. (T or F) The reserved word throw is used to signal that an exception has occurred.
  7. (T or F) The correct use of throw can be anywhere in a program; a try / catch structure is used only in class definitions.
  8. (T or F) In C++, class is not a reserved word.
  9. (T or F) Class attributes have no fixed type; their type can be changed during the program execution.
  10. (T or F) A member of a class can be a method or an attribute.
  11. (T or F)The private attributes of a class cannot be accessed by the public methods of that class.
  12. (T or F) The initialization of a variable in the declaration

Ex: int counter = 0;

is not allowed inside a class definition.

  1. (T or F) In C++ a class is a definition; it does not exist in RAM until an object is created, using the definition.
  2. (T or F) A member of a class that was created “on the stack” (locally) can be accessed by using the dot operator (.) followed by the member name.
  3. (T or F) Class objects can be passed to methods as arguments and can be returned from methods.
  4. (T or F) A class constructor is a method that automatically is called whenever an object is created from the class.
  5. (T or F) a class destructor is another name for a no-arg constructor..
  6. (T or F) a class cannot have more than one constructo
  7. (T or F) a class can have a destructor to match each constructor.
  8. (T or F) The primary purpose of the separation of a class interface from the class implementation enables the code to be more easily read by a human programmer.
  9. (T or F) Every time any method is called, a new “frame” is created in RAM.
    1. (T or F) A “pure” class definition can contain only methods.
    1. (T or F) A class definition by itself, takes very little space in RAM.

Solutions

Expert Solution

a)

The answer is false.

The c++ does not throw an exception if an element that is not present in array index bounds is tried to be accessed.

There are some default values or garbage values that are present in the memory that is allocated to the program.

These values get displayed when such elements are accessed.

In some cases, the program produces segmentation fault error.

b)

The answer is false.

When the assignment statement is used to copy one array to another it raises error.

In order to copy one array to another array, the operation should be performed on each element of the array.

Each element should be copied and moved to the second array.

c)

The answer is true.

The exceptions are the unexpected situations that arise during the run time of the program.

These are not syntactical problems. These can be handled in the program to prevent the stopping of execution of the program.

d)

The answer is false.

The try catch blocks are used for exception handling mechanisms.

The syntax errors can not be handled by the try catch blocks. These are used to test the code and handle the problems that might rise during the execution.

e)

The answer is true.

The try block must be followed by the catch block.

Each try block can have multiple catch blocks associated with it.

But there can be no other statements present between try and its associated catch block.

Note:

Please see that as per the guidelines, only single question can be answered when multiple questions are present.

In case of multiple choice type questions, upto 4 can be answered. Thank you.


Related Solutions

Raising an Exception In the previous problem, you used a try/except statement to catch an exception....
Raising an Exception In the previous problem, you used a try/except statement to catch an exception. This problem deals with the opposite situation: raising an exception in the first place. One common situation in which you will want to raise an exception is where you need to indicate that some precondition that your code relies upon has not been met. (You may also see the assert statement used for this purpose, but we won’t cover that here.) Write a function...
Let f(t)=5t2−t. a) Find f(t+h): b) Find f(t+h)−f(t): c) Find f(t+h)−f(t)/h: side note: (f(t+h)=f(t) is on...
Let f(t)=5t2−t. a) Find f(t+h): b) Find f(t+h)−f(t): c) Find f(t+h)−f(t)/h: side note: (f(t+h)=f(t) is on top of fraction and h is on bottom) d) Find f′(t): pls circle the 4 answers
(in C# please.) EXCEPTION HANDLING Concept Summary: 1. Use of try… catch in a program 2....
(in C# please.) EXCEPTION HANDLING Concept Summary: 1. Use of try… catch in a program 2. Define an exception class and call it from the driver program. For this lab you will complete two parts. Part (a) of the lab implements try… catch and uses an existing exception in C# or in Java. Write a program that implements an ArrayIndexOutOfBounds error. Part (b) writes a program that converts a time from 24-hour notation to 12-hour notation. Assume the user will...
PLease using C# Without using try-catch-throw for exception handling (Ch07), display an error message (using csc...
PLease using C# Without using try-catch-throw for exception handling (Ch07), display an error message (using csc or VS2017) when an input is invalid (i.e., no data, wrong format, wrong type, etc.) and fails the type conversion. Generate random integers from any of the following three non-overlapped ranges -14 ~ -7 -2 ~ 5 33 ~ 44 Numbers generated must also randomly distributed across the three ranges.
Please try to solve all of them True/false questions T   F         A blocking assignment in Verilog...
Please try to solve all of them True/false questions T   F         A blocking assignment in Verilog is used to synchronize assignment statements so that they appear to execute at the same time. T          F           A blocking assignment in Verilog completes execution before next statement executes. T          F           Verilog Hardware description language is case sensitive. T          F           An “if” statement must always be inside of an “always” block. T          F           Verilog may be written at the Behavioral, Structural, Gate, Switch and...
Find the Fourier series of the function. c. f(t) = sin(3pit), -1</ t </ 1
Find the Fourier series of the function. c. f(t) = sin(3pit), -1</ t </ 1
q = a(b+c(de+f)), t = !(q+a), m = aq, where the inputs are a, b, c,...
q = a(b+c(de+f)), t = !(q+a), m = aq, where the inputs are a, b, c, d, e, f and q; and outputs are t and m. Please provide the truth table. Please write the Sum of Products for the output t. Implement the Sum of Products of t with AND2, OR2 and NOT gates. Convert the previous part by using ONLY NAND2 gates. Provide MIPS code for the last part.
2. a. If you represent the allele frequencies as f(T)=p and f(t)=q, what does the Hardy-Weinberg...
2. a. If you represent the allele frequencies as f(T)=p and f(t)=q, what does the Hardy-Weinberg Equilibrium Model predict the genotype frequencies will be in the rodent population in the next generation (show the calculations)?       b. What are the assumptions of the Hardy-Weinberg Equilibrium Model?       c. What does the model predict about the genotype and allele frequencies at generations 10, 100, 1000? (Note: This is where the “Equilibrium” comes from)       d. So, the H-W Eq. Model is...
Problem 2 Find max, min, point of infliction for a. f(t)=c (e^(-bt)-e^at ) for t≥0 where...
Problem 2 Find max, min, point of infliction for a. f(t)=c (e^(-bt)-e^at ) for t≥0 where a>b>0, c>0 b. f(x)=2x^3+3x^2-12x-7 for -3≤x≤2 c. f(x)=(x+3)/(x^2+7) for -∞≤x≤+∞
Fit a quadratic function of the form ?(?)=?0+?1?+?2?2 f ( t ) = c 0 +...
Fit a quadratic function of the form ?(?)=?0+?1?+?2?2 f ( t ) = c 0 + c 1 t + c 2 t 2 to the data points (0,−1) ( 0 , − 1 ) , (1,8) ( 1 , 8 ) , (2,−7) ( 2 , − 7 ) , (3,−6) ( 3 , − 6 ) , using least squares.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT