In: Computer Science
a. (T or F) A function or method cannot return a value of type array.
b. (T or F) C++ throws an exception if you try to refer to element 47 in an array with 20 elements.
c. (T or F) I can copy one array to another by simply using an assignment statement which assigns the one array to the other.
d. (T or F) An exception is the occurrence of an erroneous or unexpected situation during the execution of a program.
e. (T or F) The try / catch structure is used to test for and catch occurrences of syntax errors.
Ans a) True
C++ does not provide us the functionality to return a value of type array. However, if we want to return an array we can use a pointer and return the first element of the array. In this statement, we are asked to return the array itself, which is not possible in C++.
Ans b) False
C++ does not define the boundary checking. Hence, for the index greater than the size of the array it will return some arbitrary value.
Ans c) False
We can't copy the entire array to any second variable by using an assignment operator. We can use std::copy function to copy the array to any second variable.
Ans d) True
Exception always occurs during the execution of the program. It mostly arises due to the logical errors in the program. eg. Divide by Zero Exception.
Ans e) False
try / catch structure is used only for the exceptions or say logical error, like Divide by Zero Exception. If the program has the syntax errors, it will show those errors during the compile time itself. There is no need of try / catch structure for syntax errors.