Knowledge Check 4 Reviewer
Copy Constructor Knowledge Check
Test your understanding of copy constructors, friend fun
Whether you're a beginner or a seasoned developer, you will find:
- 35 thoughtful questions
- A variety of topics related to C++
- Immediate feedback on your answers
These make a copy of another instance of an object.
Instantiator
Pointer
Copy-Constructor
Iterator
Which of the following is the correct syntax for a Copy Constructor?
MyClass(MyClass other);
MyClass(const MyClass& other);
When is a copy constructor called?
When an object is created from another object of the same type.
When an object is passed by value as a parameter to a function.
When an object is returned from a function.
All of the above.
Copy constructors may be called without our knowledge.
True
False
If you don't declare copy constructors, the C++ compiler will NOT generate one and copy assignment operators for you, thus resulting in a compile error.
True
False
The auto-generated copy constructor and assignment operator will just copy/assign the member variables, one by one. This concept is otherwise known as?
Cloning
Multiple Copy Constructors
Deep Copying
Shallow Copying
A _____ copy constructor must be defined if you donβt want to use the compiler supplied copy constructor. You can also define your own copy constructor.
Public
Protected
Private
None of the above.
Whenever deep copying is required, a copy constructor should be user-defined.
True
False
A class can allow non-member functions and other classes to access its own private data, through this concept known as?
Data sharing
Peer-to-peer sharing
Friends
Airdrop
Once a non-member function is declared as a friend, it can access the private data of the class.
True
False
When class X declares class Y as a friend, class Y does not automatically have access to the private data of class X.
True
False
Friend status must be explicitly declared β just because X is a friend of Y does not mean Y is a friend of X.
True
False
If Class X is a friend of Class Y and Class Y is a friend of Class Z, Class X is then necessarily a friend of Class Z via transitivity.
True
False
Which of the following displays INCORRECT declaration syntax for friends?
Friend void myFriend();
Friend class ClassTwo;
Friend main pairUp();
None of the above.
A/n _____ method can be a friend of a class. The friendship cannot be inherited. If we want to inherit the friendship we MUST explicitly declare the derived class methods also as friend.
Overloaded
Overridden
Virtual
Static
Misuse of friend feature has no bearing on encapsulation.
True
False
_____ is the process of giving a different or special meaning to an operator.
Operator overloading
Operator overriding
Method overloading
Method overriding
Which of the following statements is TRUE?
Leftmost operand must be an object (or reference to an object) of the class.
If the left operand is of a different type, the operator function must be a non-member function.
A non-member operator function must be a friend if private or protected members of that class are accessed directly.
All of the above.
In general, if the operation modifies the state of the class object it operates on, it must be a member function.
True
False
Conversely, if the operator does not modify any of its operands, but needs only a representation of the object, it also has to be a member function and is often less confusing as an external friend function.
True
False
<< operator must have a left operand of type istream& and >> operators must have a left operand of type ostream&.
True
False
Errors that occur or are caught after software development.
Logic Error
Bugs
Exceptions
Syntax Error
Errors that make the program do the wrong action. Although they are coded correctly, they cause the program to function differently than expected.
Logic Error
Bugs
Exceptions
Syntax Error
Predictable errors that can be planned for during software development.
Logic Error
Bugs
Exceptions
Syntax Error
It is any unusual event, either erroneous or not, detectable by either hardware or software, that may require special processing.
Error
Bug
Exception
Crash
The special processing that may be required after detecting an exception is called?
Exception Debugging
Rebooting
Exception Repairing
Exception Handling
A _____ block encloses code that may raise an exception.
Throw
Try
Catch
Code
This block is where exceptions are caught.
Throw
Try
Catch
Code
This type of exception presents invalid conditions in areas outside the immediate control of the program (invalid user input, database problems, network outages, absent files).
Handled Exception
Thrown Exception
Checked Exception
Unchecked Exception
This thype of exception represents defects in the program (often invalid arguments passed to a non-private method).
Handled Exception
Thrown Exception
Checked Exception
Unchecked Exception
This function is used to reduce the overhead for a function that is called many times in a program.
Recursive
Goto
Void
Inline
Functions defined within a class declaration automatically become inline functions.
True
False
The Standard C++ Library is a collection of pre-defined functions, constants, classes and objects.
True
False
Inline int max( int a, int b ) ... Is correct syntax for inline declaration.
True
False
If it is a large function (more than three or four lines), inlining can retain the size of the executable program.
True
False
{"name":"Knowledge Check 4 Reviewer", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your understanding of copy constructors, friend functions, and exception handling in C++. This quiz is designed to challenge your knowledge and help reinforce key concepts in object-oriented programming.Whether you're a beginner or a seasoned developer, you will find:35 thoughtful questionsA variety of topics related to C++Immediate feedback on your answers","img":"https:/images/course5.png"}