Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++: True or False Questions & Multiple Choice Questions Note that I didn\'t pos

ID: 3579427 • 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.

Question 1: Typically in C++, most classes have their methods marked public.

True or False?

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?

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?

Question 7: The following code:

SpaceShip s;

cin >> s;

calls the operator>> defined as:

friend SpaceShip operator>>( istream& ins, SpaceShip & s );.

True or False?

Question 8: In C++, the class logic_error is part of the namespace std and requires that programmers #include .

True or False?

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?

Question 15: Only a pointer variable can be set to have the value NULL.

True or False?

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?

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?

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?

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?

Question 23: The body of a while(...) { ... } loop may never execute depending on what test condition is stated.

True or False?

Flag this Question

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?

Question 25: Run-time parameters passed to a function allow you to use different values each time the function is called.

True or False?

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?

Question 32: The default case is required in the switch selection statement.

True or False?

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

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.

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

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

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

Q1

Generally the methods are marked as private in c++ as the and this is only suggested as it reduces the coupling

Hence false

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote