C++: True or False Questions & Multiple Choice Questions Note that I didn\'t pos
ID: 3579433 • Letter: C
Question
C++: True or False Questions & Multiple Choice Questions
Note that I didn't post all the questions. For example, there is no question 6.
Don't bother answering if you aren't going to answer all these questions. Many of the questions I just need confirmation if my answers/guesses are correct.
Question 1: Typically in C++, most classes have their methods marked public.
True or False?
T: By default, all methods are marked public.
Question 3: Given a pointer to an object o, C++ programmers use the symbol . to reference the members and methods of that pointer variable.
True or False?
F: Programmer use -> to reference members and methods
Question 4: In C++, cin, the thing we have been using to process input data, is actually an example of a class method.
True or False?
Question 5: A variable of any type can be set to have the value NULL.
True or False?
T?
Question 7: The following code:
SpaceShip s;
cin >> s;
calls the operator>> defined as:
friend SpaceShip operator>>( istream& ins, SpaceShip & s );.
True or False?
T?
Question 8: In C++, the class logic_error is part of the namespace std and requires that programmers #include .
True or False?
T?
Question 10: Left uncaught, a thrown exception will cause a compile error in Visual Studio or XCode.
True or False?
Question 11: In C++, the friend operator< comes in two overloaded forms, one that takes one argument and one that takes two arguments.
True or False?
Question 13: Typically, class constructors are overloaded to provide many different and convenient ways to create an object.
True or False?
T?
Question 15: Only a pointer variable can be set to have the value NULL.
True or False?
F?
Question 17: A throw(...); statement is an alternative way to return from a function or method that indicates some kind of failure occurred.
True or False?
Question 18: Only a class method can be marked virtual.
True or False?
F?
Question 19: For a class Foo, one difference between a variable declared Foo * and a variable declared Foo & is that only the variable declared Foo & can potentially have the value NULL.
True or False?
F?
Question 20: Whenever they are passed as parameters to a function, the IO classes istream and ostream must be passed using a pass-by-value parameter passing scheme.
True or False?
T?
Question 21: When no class constructors are supplied by the author of a class, C++ itself supplies a default constructor that does nothing.
True or False?
T?
Question 23: The body of a while(...) { ... } loop may never execute depending on what test condition is stated.
True or False?
T?
Question 24: In an infinite while loop, the expression controlling the loop will initially evaluate to false, but after the first iteration it will always evaluate to true.
True or False?
F?
Question 25: Run-time parameters passed to a function allow you to use different values each time the function is called.
True or False?
T?
Question 26: A function defined to return void may not have even a single return statement.
True or False?
Question 27: In C++, arrays can be passed as parameters to a function either by value or by reference.
True or False?
Question 28: In C++, a class is allowed to have more than one constructor.
True or False?
Question 29: In addition to redefining existing operators, C++ allows programmers to create their own new operators.
True or False?
Question 30: When authoring a virtual function, the keyword virtual only appears in the .h file, not the .cpp file.
True or False?
Question 31: An exception is an occurrence of an undesirable situation that can be detected during program execution.
True or False?
T?
Question 32: The default case is required in the switch selection statement.
True or False?
F?
Question 33: Which of the following declarations for a function is valid and legal in C++?
a. All of the choices listed are valid C++ function declarations
b. int foo( char x );
c. None of the choices listed are valid C++ function declarations
d. foo( int a, int b );
e. void foo
Question 34: Consider the following function declaration:
int foo( int a, int b, int c, int d=12, int e=20 );
What is the fewest number of parameters that must be passed at run-time to call this function?
a. 3
b. 5
c. 4
d. 2
e. 0
f. 1
a?
Question 35: All of the following are reserved keywords in C++ EXCEPT
a. this
b. for
c. friend
d. tryorfail
e. class
Question 36: When a class method is marked with the keyword friend in a .h file,
a. it will be required for C++ programmers to mark that class method with the keyword friend in the class' .cpp file.
b. it will be a link error if C++ programmers mark that class method with the keyword friend in the class' .cpp file.
c. it will be a run-time error if C++ programmers mark that class method with the keyword friend in the the class' .cpp file.
d. None of the choices listed here are correct
e. it will be a compile error if C++ programmers mark that class method with the keyword friend in the class' .cpp file.
b?
Question 37: When a class method is marked with the keyword const in a .h file,
a. it will be a compile error if C++ programmers mark that class method with the keyword const in the class' .cpp file.
b. it will be required for C++ programmers to mark that class method with the keyword const in the class' .cpp file.
c. it will be a link error if C++ programmers mark that class method with the keyword const in the class' .cpp file.
d. it will be a run-time error if C++ programmers mark that class method with the keyword const in the class' .cpp file.
e. None of the choices listed here are correct
e?
Question 38: If operator << is supported by a class, how many parameters should it be defined to accept?
a. 1
b. 2
c. 3
d. 0
b?
Question 39: If operator- is supported by a class, how many parameters should it be defined to accept?
a. 1 or 2
b. 2
c. 1
d. 3
e. 0
Question 40: A member of the class Sample that is marked private
a. is accessible by any subclass of Sample
b. is accessible by any parent class of Sample
c. is accessible by driver code
d. is not accessible by any code outside the class Sample
Explanation / Answer
Question 10: Left uncaught, a thrown exception will cause a compile error in Visual Studio or XCode.?
Answer : True
Question 15: Only a pointer variable can be set to have the value NULL?
Answer: true
Question 18: Only a class method can be marked virtual.?
Anser: True
Question 19: For a class Foo, one difference between a variable declared Foo * and a variable declared Foo & is that only the variable declared Foo & can potentially have the value NULL.?
Answer : False
Question 20: Whenever they are passed as parameters to a function, the IO classes istream and ostream must be passed using a pass-by-value parameter passing scheme.?
Answer : True
Question 23: The body of a while(...) { ... } loop may never execute depending on what test condition is stated.?
Answer: False
Question 24: In an infinite while loop, the expression controlling the loop will initially evaluate to false, but after the first iteration it will always evaluate to true.?
Answer: false
Question 29: In addition to redefining existing operators, C++ allows programmers to create their own new operators.?
Answer : True :c++ allows programmers to cretare therir own new operations
Question 40: A member of the class Sample that is marked private
Answer : a. is accessible by any subclass of Sample
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.