Ad

Chapter - 5: Classes in C++

State True and False


Ad
A
Sections
1
Exercises

(a) By default members of a structure are public and that of a class are private.
True.

(b) Nested classes are illegal.
False

(c) In a class data members are always private, whereas, member functions are always public.
False: It depends on the programmer to make it public or private.

(d) It is necessary that a constructor in a class should always be public.
True.

(e) If a class contain a 3-argument costructor then it is necessary to define explicitly a zero-argument, a 1-argument, and a 2-argument constructor.
False: Only zero-argument constructor is necessary.

(f) Member functions of a class have to be called explicitly, whereas the constructor gets called automatically.
True.

(g) A constructor is called whenever an object is instantiated.
True.

(h) Constructors can be overloaded.
True.

(i) A constructor never returns a value
True.

(j) Static memory allocation takes place during compilation, whereas dynamic memory allocation takes place during execution.
True.

(k) Size of an object is equal to the sum of sizes of data members and member functions within the class.
False: No, size does not depend on the member functions of the class.

(l) If the ++ operator has been overloaded then the expressions j++ and ++j would call the same overloaded function.
False: We have to define different functions for each operator.

(m) When an object goes out of scope its destructor gets called automatically.
True.

(n) If the binary + operator is overloaded inside the class then while calling it only one argument needs to be passed.
True.

(o) The this pointer always contains the address of the object using which the member function/data is being accessed.
True.

(p) The this pointer can be used even outside the class.
False: It is only used the members of the class.

(q) If the member functions are declared outside the class it is necessary to declare them inside the class.
True.

Ad

© 2024 Garbage Valuegarbage value logo