How well do you think you know C++?
Start Congratulations - you have completed C++ Theory.
You scored %%SCORE%% out of %%TOTAL%%.
Your performance has been rated as %%RATING%%
Your answers are highlighted below.
Question 1
What can a class contain?
Member functions only.
Data members only.
Member functions and data members.
Question 2
What are the access privileges in C++?
public
protected
private
internal
Question 3
Whan are copy constructors called?
When a function returns an object of tha class by value.
When a function returns an object of tha class by reference.
When the object of that class is passed by value as an argument to a function.
Question 4
Choose the case where you can not throw an exception.
When a constructor fails.
When a destructor fails.
When the creation of a new object fails.
When you cannot open a file.
Question 4 Explanation:The C++ rule is that you must never throw an exception from a destructor that is being called during the “stack unwinding” process of another exception. Further Explanation
Question 5
What are the differences between malloc()/free() and new/delete? (Choose all that apply)
malloc allocates memory for object in heap while new allocates memory for object in free store.
new and delete can be overloaded in a class.
Malloc but doesn’t invoke object’s constructor to initiallize the object. new invokes constructor to initialize the object.
Question 6
Which of the following apply for static functions?
A static member function cannot have access to the ‘this’ pointer of the class.
A static member function can only access static member data, static member functions and data and functions outside the class.
The static function operates on the class and not in object.
A static function cannot be used if the class is not instantiated.
Question 7
Which of the following operators can be overloaded?
sizeof
+
-
::
*
Question 8
Which of the following does a derived class inherit?
Data Members
Constructor
Function Members
Destructor
overloaded = operator
Once you are finished, click the button below. Any items you have not completed will be marked incorrect.
Get Results
There are 8 questions to complete.
List
Return
Shaded items are complete.
1
2
3
4
5
6
7
8
End
Return
You have completed
questions
question
Your score is
Correct
Wrong
Partial-Credit
You have not finished your quiz. If you leave this page, your progress will be lost. All doneNeed more practice!Keep trying!Not bad!Good work!Perfect!