COP3330 Exam with complete
solutions latest version
if cptr is a pointer to an object of type Cow, then the notation cptr->Moo( ); is equivalent
to which of the following:
a. *cptr.Moo( );
b. *cptr->Moo( );
c. (*cptr).Moo( );
d. cptr[0]->Moo( ); - CORRECT ANSWER-c
if a member function of class Player is protected, this means it is accessible from:
a. within class Player and any class derived from Player
b. inside class Player only
c. within class Player and any class that Player is derived from
d. anywhere - CORRECT ANSWER-a
which of the following is a correct prototype for the assignment operate overload
member function in a class called Button?
a. Button& operator= (Button &, const Button &);
b. Button& operator= (const Button &);
c. Button (const Button &);
d. Button = (Button &); - CORRECT ANSWER-b
a function in a derived class that has the same prototype as a function in its base class
is said to _____ the base class function.
a. inherit
b. eliminate
c. override
d. overload - CORRECT ANSWER-c
given a pointer declared as monkey* barrel; (where monkey is a class). How does one
dynamically allocate an array of 25 monkey objects?
a. new monkey[25] = barrel;
b. barrel = new monkey barrel [25];
BRAINSCAPE1
, BRAINSCAPE1
c. monkey = new barrel [25];
d. barrel = new monkey[25]; - CORRECT ANSWER-d
which of the following statements correctly de-allocated the dynamic array created in
the last question?
a. delete [ ] barrel;
b. delete [ ] monkey;
c. delete *barrel;
'd. ~monkey( ); - CORRECT ANSWER-a
from inside a member function, the keyword this is...
a. a pointer to a parameter of the function
b. the name of the calling object
c. a reference variable to the member function
d. a pointer to the calling object - CORRECT ANSWER-d
for which of the following situations is a copy constructor invoked?
a. when an object is returned from a function by reference
b. when an object is passed into a function by value
c. when a pointer to an object is passed into a function
d. when an object is passed into a function by const reference - CORRECT ANSWER-b
given the declaration: int* ptr; which of the following CANNOT be assigned into ptr?
a. the value of the iptr, a pointer to int
b. the name of an array of type int
c. *x, where x is of type int
d. the value 0 - CORRECT ANSWER-c
suppose Duck is a class and bill and mr_quacks are objects of type Duck. which of the
following statements will invoke the copy constructor for class Duck?
a. Duck waddles = bill;
b. Duck fluffy(mr_quacks.GetHeight( ));
c. bill = mr_quacks;
d. mr_fluffy = bill.copy( );e. none of the above - CORRECT ANSWER-a
consider the declaration: virtual int Ring(int x) = 0; Assume this declaration is in a class
called Phone. The "=0" on the declaration means:
a. the Ring function returns the value 0
b. the Ring function will not be defined for any class derived from Phone
c. the Ring function will be defined for all classes derived from class Phone
d. the Ring function will not be defined for the Phone class - CORRECT ANSWER-d
given the following code statements, what will print to the screen?char animal [ ] = {'S',
'n', 'a', 'k', 'e'};cout << animal;
a. the word Snake (and nothing else)
b. the word Snake and possibly some other random characters after
c. just the letter 'S'
BRAINSCAPE1