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

C++ True and False Questions _____ F _____ The copy constructor is always called

ID: 3868009 • Letter: C

Question

C++ True and False Questions

_____ F _____ The copy constructor is always called during the declaration of an object _____ F _____ Function overloading is used when different functions have the same implementation _____ T _____ Friend functions of a class have access to its private members. _____ F _____ The function "new" allows us to allocate memory during compile time. _____ T _____ The function "delete" is used to de-allocate memory allocated by "new." _____ F _____ The compiler requires that identifiers indicate the purpose of what they name. _____ F _____ "this" is an object. _____ F _____ All members of a structure are private by default. _____ T _____ Declarations can appear almost anywhere in the body of a C++ program. _____ F _____ An instance of a user-defined type is called a class void functions do not have parameters. _____ F _____ An array is accessed randomly, because the first element is accessed quicker than the last element in the array. _____ F _____ Objects can be passed explicitly to *this. _____ T _____ Pointers can be passed by referenced. _____ T _____ When an object of a class is declared memory is allocated. _____ T _____ When an object of a class is declared memory is allocated _____ T _____ The copy constructor is called during a call-by-value _____ T _____ The return statement in a called function is used to pass the value of an expression back to the calling function _____ F _____ The state of a class is the public data members. _____ T _____ Accessor functions never change the state of an object. _____ F _____ A deep copy is a bit-by-bit copy done by the copy constructor _____ T _____ Overloaded functions can have the same name and return type, but they must have different argument lists.

Explanation / Answer

Que 1) False

Explaination:

A copy constructor is a member function of a class which initializes an object using another object of the same class. But the point to be noted is that it is not necessary to that copy constructor is always called when a object is declaired.

Que 2. False

Explaination:

In c++ we can declair two different functions with same name but having different parameters, this feature is called function overloading.

Que 3) True

Explaination:

Friend functions are speacial functions in c++ which have access to private variables of the class

Que 4) False

Explaination: In c++ memory is allocated in two ways

1) At compiling time: For variables of fixed size like arrays.

2) At Running time: For variables of dynamic size like vectors. "new "keyword allocates new memory at running time and not at compiling time

Que 5 True

Explaination: "delete" function is used to de-allocate the memory allocated by "new" function. And . A operand is used which is pointer that stores the address of the space to be deallocated.

Que 6 False

Explaination: An Identifier is simply a name which uniquely represents a object of class. The name do not need to have any relation with purpose of that object.

Que 7 False

Explaination: ‘this’ is a constant pointer that holds the memory address of the current object of a class.

Que 8 False

Explaination: All members of a structure are public members by default.

Que 9 True

Explaination: Yes, we can declair variables almost anywhere in c++ program.

Que 10 False

Explaination: An instance of user defined type/class is called object.

Que 11 False

Explaination: Void functions do not return anything.

Que 12 False

Explaination: Accessing any element in an array whether it is the first element or last element takes the same amount of time.

Que 13 False

Explaination: ‘this’ is a constant pointer that holds the memory address of the current object of a class.

Que 14 True

Explaination: Double pointers are used to pass pointer by reference.

Que 15 True

Explaination: Memory is allocated at the time when object is declaired.

Que 16 True

Explaination: A copy constructor is a member function of a class which initializes an object using another object of the same class.

Que 17 True

Explaination: Returns statement returns a value to the calling function.

Que 18 False

Explaination: All members of a class are private members by default.

Que 19 True

Explaination: Accesor function changes the value of copy of object, not the value of actual object.

Que 20 False

Explaination: Shallow copy is defined as a bit by bit copy, not deep copy.

Que 21 True

Explaination:In c++ we can declair two different functions with same name but having different parameters, this feature is called function overloading.

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