Filters
Question type

Study Flashcards

While a class's member functions may be overloaded, the constructor cannot be overloaded.

A) True
B) False

Correct Answer

verifed

verified

What is the output of the following program? #include <iostream> using namespace std; class TestClass { Public: \quad TestClass(int x) \quad { cout << x << endl; } \quad TestClass() \quad { cout << "Hello!" << endl; } }; Int main() { \quad TestClass test; \quad return 0; }


A) the program runs but there is no output.
B) 0
C) Hello!
D) the program will not compile

E) None of the above
F) B) and C)

Correct Answer

verifed

verified

Objects in an array are accessed with __________.


A) subscripts
B) parentheses
C) #include statements
D) output format manipulators
E) None of these

F) A) and B)
G) A) and C)

Correct Answer

verifed

verified

Destructor functions are often used to free memory that was allocated by the object.

A) True
B) False

Correct Answer

verifed

verified

Assume that myCar is an instance of the Car class and that the Car class has a member function named accelerate. Which of the following is a valid call to the accelerate member function?


A) Car -> accelerate() ;
B) myCar::accelerate() ;
C) myCar.accelerate() ;
D) myCar:accelerate() ;
E) None of these

F) C) and D)
G) B) and D)

Correct Answer

verifed

verified

Constructor functions are often used to allocate memory that will be needed by the object.

A) True
B) False

Correct Answer

verifed

verified

For the following code, which statement is not true? Class Point { Private: Double y; Double z; Public: Double x; };


A) x is available to code that is written outside the class.
B) The name of the class is Point.
C) x, y, and z are called members of the class.
D) z is not available to code that is written outside the class.
E) All of these are true.

F) A) and D)
G) C) and D)

Correct Answer

verifed

verified

Class objects can be defined prior to the class declaration.

A) True
B) False

Correct Answer

verifed

verified

In C++11 you can have one constructor call another constructor in the same class by using


A) constructor delegation
B) in-place initialization
C) a member initialization list
D) None of these

E) A) and C)
F) A) and D)

Correct Answer

verifed

verified

The destructor function's return type is


A) int
B) float
C) char
D) Nothing; destructors have no return type
E) None of these

F) C) and E)
G) A) and D)

Correct Answer

verifed

verified

Where are class declarations usually stored?


A) on separate disk volumes
B) in their own header files
C) in .cpp files, along with function definitions
D) under pseudonyms
E) None of these

F) A) and D)
G) B) and E)

Correct Answer

verifed

verified

When a constructor has a member initialization list, the initializations take place


A) after any statements in the body of the constructor execute
B) before any statements in the body of the constructor execute
C) when a member is used in the execution of the program
D) None of these

E) None of the above
F) A) and C)

Correct Answer

verifed

verified

Which of the following is a directive used to create an "include guard" that allows a program to be conditionally compiled to prevent a header file from accidentally being included more than once?


A) #include
B) #guard
C) #ifndef
D) #endif
E) None of these

F) C) and D)
G) A) and B)

Correct Answer

verifed

verified

Which of the following is automatically called when an object is destroyed?


A) the constructor function
B) the specification deallocator
C) the destructor function
D) the destruction function
E) None of these

F) A) and B)
G) None of the above

Correct Answer

verifed

verified

Showing 41 - 54 of 54

Related Exams

Show Answer