Quiz 2-3

Cards (94)

  • Suppose str = "ABCDEFGHI" the value of str.length() is 8 since the position of the first character is 0.True or False?
    False
  • The heading of a try block can contain ellipses in place of a parameter. True or False?
    False
  • The length of the string "Hello There." is ___.
    12
  • The ______ function is used to interchange the contents of two string variables.

    swap
  • The function ______ can check whether an expression meets the required conditions; if the conditions are not met, it terminates the program.

    assert
  • If, during program execution, division by zero occurs with integer values and is not addressed by the program, the program might simply hang. True or False?
    True
  • Suppose str = "abcd". After the statement str = str + "ABCD"; the value of str is "ABCD". True or False?
    False
  • The length of string "Hello There!" is 12. True or False?

    True
  • Which of the following blocks is designed to catch any type of exception?
    catch(...){}
  • The function substr returns true if its second argument is a substring of its first parameter. True or False?
    False
  • The function ______ returns a string containing an appropriate message.

    what
  • Consider the statement string str1 = ""Gone with the wind""; string str2; str2 = str1.substr(5, 4); The value of str2 is "___".
    with
  • When an exception is thrown in a function, the function cannot throw a new exception.True or False?
    False
  • Suppose str = "xyzw". After the statement str[2] = "Y"; the value of str is "xYzw".True or False?
    False
  • If no exception is thrown in a try block, all catch blocks associated with that try block are executed.True or False
    False
  • In C++, the null character is represented as ___.
    '\0
  • Consider the following statement string str = "ABCDEFD"; position = str.find('D'); position is equal to ___.
    3
  • In C++, throw is a reserved word.True or False?
    True
  • In some exception cases, you will want to handle the exception and let the program continue. True or False?
    True
  • One common way to provide exception handling is to add exception-handling code to the header file. True or False?
    False
  • Consider the following statement string str1 = "ABCDEFGHIJKLM"; string str2; The statement str2 = str1.substr(1, 4); The value of str2 is "___".
    BCDE
  • The statements that may generate an exception are placed in a ______ block.
    try
  • The order of the catch blocks does not affect the program. True or False?
    False
  • To use the assert function in your program, you should include the statement ____.
    #include
  • If the operator new cannot allocate memory space, this operator throws overflow_error exception. True or False?
    False
  • Before using the data type string, the program must include the header file ___.
    string
  • Which of the following correctly declares names to be a character array stores "William" in it?
    char name[8] = "William";
  • A catch block can have, at most, ___ catch block parameter(s).
    one
  • Suppose str = "TiNa"; After the statement str[2] = 'I'; What is the value of str?
    TiIa
  • If the catch block with an ellipses (in the heading) is needed, then it should be the first catch block in a sequence of try/catch blocks.
    False
  • One of the typical ways of dealing with exception is to use an if statement. True or False?
    True
  • To deal with logical errors in a program, such as a string subscript out of range or an invalid argument to a function call, several classes are derived from the class ______.
    exception
  • A(n) _____ is an occurrence of undesirable situation that can be detected during program execution.
    exception
  • Consider the statement string str = "Gone with the wind"; the output of the statement cout<< str.find("the") << endl; is ___.
    10
  • When determining the length of a string, embedded blank spaces are ignored. True or False?
    False
  • When division by zero occurs and the problem is not addressed, the program crashes with an error message that is _____ dependent.
    IDE
  • A catch block can have up to two catch block parameters. True or False?
    False
  • The try block is followed by one or more ____ blocks.
    catch
  • In a sequence of try/catch blocks, the last catch block of the sequence should be ___.
    catch(...){}
  • Which of the following is a valid C++ statement?
    assert (divisor != 0);