0% found this document useful (0 votes)
20 views

CS304P Lab Quiz No 4 by @Studywithhamza25

The document is a quiz for a CS304P lab, containing multiple-choice questions related to class access specifiers, destructors, static data members, and member functions in programming. It includes warnings against copying the file and offers contact information for quiz solutions and WhatsApp group invitations. The quiz consists of 20 questions, each with several answer options regarding programming concepts.

Uploaded by

Khadija Nisar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

CS304P Lab Quiz No 4 by @Studywithhamza25

The document is a quiz for a CS304P lab, containing multiple-choice questions related to class access specifiers, destructors, static data members, and member functions in programming. It includes warnings against copying the file and offers contact information for quiz solutions and WhatsApp group invitations. The quiz consists of 20 questions, each with several answer options regarding programming concepts.

Uploaded by

Khadija Nisar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CS304P LAB QUIZ#4

LATEST ATTEMPT BY
@studywithhamzA25
WARNING
(Don’t Copy My File)
PAID QUIZ CONTACT
03147094561
LMS HANDLING SERVICES AVAILABLE
Join Whatsapp Group For Latest
Solutions

Join Now
WHATSAPP GROUP1
Join NOW
WHATSAPP GROUP 2
Join NOW
Join WHATSAPP CHANNEL
JOIN NOW
1. Which of the following is the default access specifier
for members of a class?
a. private
b. protected and public
c. public
d. protected and private
2. Which of the following is correct way of declaring the
attribute as a public?
a. class public Student { char *name;};
b. class Student public: { char *name;};
c. class Student { char *name;};
d. class Student { public: char *name;};
3. Which of the given option is not correct for destructor?
a. Destructor is a function with the same name as that of
class but preceded with a tilde ~
b. Destructor is a function with the same name as
that of class, but preceded with a tilde 'void ~'
c. Destructor is used to free the memory allocated
through new operator.
d. Destructor is used to free the memory allocated
through dynamic allocation.
4. Which of the following option is false?
a. Private members can be accessed using friend
functions
b. Public members are accessible from other classes also
c. Member functions can be made private
d. Data members can’t be inherited
5. Following code is equivalent to which option.
a. class Shape
b. {
c. string type;
d. };
e. class Shape { public: string type; };
f. class Shape { private: string type; };
g. class Shape public: { public: string type; };
h. class Shape { protected: string type; };
6. Which of the following is the default access specifier
for members of a class?
a. protected and public
b. private
c. protected and private
d. public
7. Following code is equivalent to which option.
a. class Shape
b. {
c. string type;
d. };
e. class Shape { private: string type; };
f. class Shape { protected: string type; };
g. class Shape { public: string type; };
h. class Shape public: { public: string type; };
8. In classes which of the following is default access
specifier?
a. Private
b. None of the given option
c. Public
d. Protected
9. Which of the following is correct way of declaring the
attribute as a public?
a. class Student public: { char *name;};
b. class Student { char *name;};
c. class Student { public: char *name;};
d. class public Student { char *name;};
10. Which of the given option is not correct for
destructor?
a. Destructor is a function with the same name as
that of class, but preceded with a tilde 'void ~'
b. Destructor is used to free the memory allocated
through new operator.
c. Destructor is a function with the same name as that of
class but preceded with a tilde ~
d. Destructor is used to free the memory allocated
through dynamic allocation.
11. Which statement is true about life of a static data
member?
a. Static data members are destroyed when single object of a class is destroyed.
b. Static members are destroyed dynamically.
c. Static data member exists only within the scope of the class constructor.
d. They remains in memory even if all objects are
destroyed.
12. Which of the following option correctly declares a
static variable ‘x’ ?
a. int static x;
b. static x int;
c. int x static;

d. static int x;
13. Static data members are shared by _____ of the
class.
a. Private data members
b. Public data members
c. Protected data members
d. All types of data members

Static data member is declared ___ the class, but they


14. “

are defined ___ the class.”


a. Choose the correct sequence of data member declaration and definition.
b. Outside, Outside
c. Inside, Inside
d. Inside, Outside
e. Outside, Inside
15. Which statement is not true for static member
functions?
a. Access mechanism for static member functions is same as that of static data members.
b. They cannot access any non-static members.
c. They are capable to access static as well as non-
static member functions.
d. They are used to access static data members.
16. Which of the following option correctly declares a
static variable ‘x’ ?
a. static int x;
b. int x static;
c. static x int;
d. int static x;
17. Which statement is true about life of a static data
member?
a. Static members are destroyed dynamically.
b. Static data members are destroyed when single object of a class is destroyed.
c. They remains in memory even if all objects are
destroyed.
d. Static data member exists only within the scope of the class constructor.
18. Which of the following keyword should be used to
declare a static variable?
a. stat
b. static
c. const
d. global
19. Static data members are shared by _____ of the
class.
a. Protected data members
b. Public data members
c. Private data members
d. All types of data members
20. Which statement is not true for static member
functions?
a. They are used to access static data members.
b. They cannot access any non-static members.
c. They are capable to access static as well as non-
static member functions.
d. Access mechanism for static member functions is same as that of static data members.
SUBSCRIBE MY
YOUTIBE CHANNEL
SUBSCRIBE NOW

THANK YOU!

You might also like