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?
|
int |
||
|
ifstream |
||
|
ofstream |
||
|
string |
10 points
QUESTION 4
A throw block is where
|
a catch takes place |
||
|
an exception is handled |
||
|
where execution continues after an exception |
||
|
an exception may be thrown |
10 points
QUESTION 5
For two strings defined and initilized as:
string string1 = "Hello";
string string2 = "Hello there";
Which operation returns true?
|
string1 <= string2 |
||
|
string1 < string2 |
||
|
string1 == string2 |
||
|
string1 < string2 |
10 points
QUESTION 6
Which function returns a double data type?
|
cin.get(); |
||
|
itoa() |
||
|
atoi() |
||
|
atof() |
10 points
QUESTION 7
Which statement can collect a string containing spaces from the keyboard?
Provided
string strObj;
|
cout << strObj + "space"; |
||
|
strObj.c_str(); |
||
|
cin >> strObj; |
||
|
getline(cin, strObj); |
10 points
QUESTION 8
A string function that returns a character at a specified index is
|
find() |
||
|
c_str() |
||
|
at() |
||
|
size() |
10 points
QUESTION 9
If strObj is defined as:
string strObj = "This cannot be";
which statement results in strObj of length 21 characters?
|
strObj += " correct"; |
||
|
strObj.find("be"); |
||
|
strObj.replace(12, 6, "to"); |
||
|
strObj.insert(4, " I know"); |
10 points
QUESTION 10
A string function that returns a boolean value is
|
compare() |
||
|
at() |
||
|
find() |
||
|
empty() |
1) all listed 2) a try-catch block 3) 9.4 is required to answer this. 4) an exception may be thrown 5) string1 < string2 6) atof() 7) getline(cin, strObj); 8) at() 9) strObj.insert(4, " I know"); 10) empty()
QUESTION 1 If an exception is thrown None listed all listed execution terminates if there is...
absolute C++
QUESTION 1 Which statement is incorrect? When an event occurs that cannot be managed locally, an exception may be thrown. Throwing the exception object transfers control and information gleaned locally to some calling program unit that manages the event, or the program terminates If an exception is thrown in a function, sayf, but not handled there, the exception is propagated to the function that called fo In C++, an exception object can be a user-defined type or any...
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 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....
Write the C# code and make a screenshot of the output according to tasks given below: Create a class named Prism with protected data fields named height and volume (Use double data type for the fields) [5 points] Include public properties for each field. The Height and Volume properties should have get and set accessors. [5 points] Add default constructor which sets the value of Height and Volume properties to 1 and 1 respectively. [5 points] Add overloading constructor which...
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...
I need help programming this question using C language. This program uses input data entered in command line at the same time when the command or .exe file is entered. They are called command-line arguments. Because everything entered in command line is taken as a string, these arguments including the command itself or the .exe file name are stored in an array of char pointers, each pointer points to the first character of a string (i.e., argument). The inputs can...
Python3 please use while loop to solve this question,specific
information is on the graph
Question 2 - 15 marks Write the function read_file_center50 (filename). The function returns a list of 50 strings that are at the center of the file. A file has n lines, then is the center. A list of length 50 is returned, where the first line is 25 and the last line is 2 + 25. If the file has n < 50 lines, then only...
-------------------------------------------------------------------- 1. How does Java support the concept of encapsulation? -------------------------------------------------------------------- 2. Describe the difference between an object and a class. -------------------------------------------------------------------- 3. What is the difference between the contents of a Java variable of a primitive type and a Java variable of a class type? -------------------------------------------------------------------- 4. (a) How is a 'static' class method different from a regular (non-static) class method? (b) How is a 'static' variable in a class different from a regular (instance) variable in a class?...
Name: True/False & Multiple Choice (2 points each) (True / False ) 2 A char literal '2', a string literal "2", and the numeric literal 2 are identical and stored the same way though they are different types. 3 Since comments do not affect the program execution, you don't need to have it at all. 4. After the following statements are executed, the value of the variable rem is 3. 1. A preprocessor directive line starts with a pound sign...
In this assignment you are going to handle some basic input operations including validation and manipulation, and then some output operations to take some data and format it in a way that's presentable (i.e. readable to human eyes). Functions that you will need to use: getline(istream&, string&) This function allows you to get input for strings, including spaces. It reads characters up to a newline character (for user input, this would be when the "enter" key is pressed). The first...