Multiple Choice Questions on Object-oriented Programming Concepts, Lecture notes of Computer Programming

15 multiple choice questions about object-oriented programming concepts such as classes, structs, member functions, constructors, and destructors. The questions cover various aspects of these concepts, including syntax, access specifiers, and function definitions.

Typology: Lecture notes

2012/2013

Uploaded on 04/27/2013

kid
kid 🇮🇳

4.3

(18)

110 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Question 1
Object-oriented programming primarily focuses on the
(a) classes.
(b) functions.
(c) variables.
(d) interface.
Question 2
The proper format for a struct is
(a) struct Time
int hour
int minute;
(b) struct Time {
int hour,
int minute,
}
(c) struct Time {
int hour;
int minute;
}
(d) struct Time {
int hour;
int minute;
};
Question 3
structs are not allowed to contain
(a) pointers to structs of different types.
(b) structs of the same type.
(c) pointers to themselves.
(d) both floats and ints.
pf3
pf4
pf5

Partial preview of the text

Download Multiple Choice Questions on Object-oriented Programming Concepts and more Lecture notes Computer Programming in PDF only on Docsity!

Question 1 Object-oriented programming primarily focuses on the (a) classes. (b) functions. (c) variables. (d) interface.

Question 2 The proper format for a struct is (a) struct Time int hour int minute; (b) struct Time { int hour, int minute, } (c) struct Time { int hour; int minute; } (d) struct Time { int hour; int minute; };

Question 3 struc ts are not allowed to contain (a) pointers to struc ts of different types. (b) struc ts of the same type. (c) pointers to themselves. (d) both floa ts and in ts.

Question 4 Which of the following is not true? (a) classes contain both data members and member functions (b) a class definition must be terminated with a semicolon (c) all classes can be represented as structs (d) the body of a class definition is delineated with left and right braces

Question 5 Member access specifiers (public and privat e) can appear (a) in any order and multiple times. (b) in any order (public first or private first) but not multiple times. (c) in any order and multiple times, if they have brackets separating each type. (d) multiple times, but all specifiers of the same type must be grouped together.

Question 6 Member function definitions (a) always require the binary scope operator (: :). (b) only require the binary scope operator when being defined outside of the scope of their class. (c) can use the binary scope operator anywhere, but become public functions. (d) must use the binary scope operator in their function prototype. Question 7 Variables defined inside a member function of a class have (a) file scope. (b) class scope. (c) function scope. (d) class or function scope, depending on whether the binary scope resolution operator (: :) is used.

Question 8 By default, class variables declared without an access modifier

(d) member functions.

Question 13 A class may contain multiple constructors if (a) they have different names. (b) they have different argument lists. (c) they have the same argument list. (d) they have different return types.

Question 14 Which of the following is not true of a constructor and destructor of the same class? (a) they both have same name aside from the tilde ( ~) character. (b) they are both called once per object (in general). (c) they both are able to accept default arguments. (d) both are called automatically, even if not defined in the class.

Question 15 Given the class definition class CreateDestroy { public: CreateDestroy() { cout << "constructor called, "; } ~CreateDestroy() { cout << "destructor called, "; } }; What will the following program output? int main() { CreateDestroy c1; CreateDestroy c2; return 0; }

(a) constructor called, destructor called, constructor called, destructor called (b) constructor called, destructor called

(c) constructor called, constructor called (d) constructor called, constructor called, destructor called, destructor called