1 you specify an individual member of a structure by using a the assignment operator 5346835

1.      You specify an individual member of a structure by using:

a.   the assignment operator.

b.   an ampersand.

c.   an underscore.

d.   the dot operator.

2.      What is wrong with the following structure definition?

struct MyStruct

{

int size;

float weight;

}

a.   Nothing is wrong with the structure definition.

b.   It cannot have mixed data types in a structure.

c.   There is a missing semicolon.

d.   Braces are not needed.

3.      When defining a class, the class should be composed of the kind of values a variable of the class can contain, and:

a.   member functions for that class.

b.   the keyword private.

c.   other class definitions.

d.   nothing else.

4.      Which of the following is the correct function definition header for the getAge function which is a member of the Person class?

a.   int getAge();

b.   int getAge()

c.   int Person:getAge()

d.   int Person::getAge()

5.      Why do you want to usually make data members private in a class?

a.   Ensure data integrity

b.   Provide data abstraction

c.   Provide information hiding

d.   All of the choices apply.

6.      A member function of a class should be made private:

a.   always.

b.   only if it will never be used.

c.   if it will only be used by other members of the class.

d.   never; it is illegal to make a member function private.

7.      A member function that allows the user of the class to change the value in a data member is known as a(n):

a.   mutator function.

b.   mutation.

c.   manipulator function.

d.   accessor function.

8.      A member function that allows the user of the class to see the value in a data member is known as a(n):

a.   mutator function.

b.   mutation.

c.   manipulator function.

d.   accessor function.

9.      A class member function that automatically initializes the data members of a class is called a(n):

a.   init function.

b.   operator.

c.   constructor.

d.   cast.

10.    If you have a class named myPersonClass, which of the following correctly declares a constructor in the class definition?

a.   myPersonClass::myPersonClass();

b.   myPersonClass();

c.   init();

d.   cast();

11.    Given the following class definition, what is missing?

class ItemClass

{

public:

ItemClass(int newSize, float newCost);

int getSize();

float getCost();

void setSize(int newSize);

void setCost(float newCost);

private:

int size;

float cost;

};

a.   Nothing

b.   A default constructor

c.   Accessor functions

d.   Mutator functions

12.    A data type consisting of data members and operations on those members which can be used by a programmer without knowing the implementation details of the data type is called a(n):

a.   abstract definition type.

b.   available data type.

c.   abstract data type.

d.   primitive data type.

13.    Developing an ADT means that the user of your class does not have to know the details about how the class is implemented.  This is known as:

a.   interface.

b.   implementation.

c.   testing and debugging.

d.   information hiding.

14.    Given the following class, what would be the best declaration for a mutator function that allows the user of the class to change the age?

class Wine

{

public:

Wine();

int getAge();

float getCost();

private:

int age;

float cost;

}

a.   int getAge(int newAge);

b.   Wine();

c.   void setAge();

d.   void setAge(int newAge);

15.    Given the following class, what would be the best declaration for a constructor that would allow the user to initialize the object with an initial age and cost?

class Wine

{

public:

Wine();

int getAge();

float getCost();

private:

int age;

float cost;

}

a.   int getAge(int newAge);

b.   Wine();

c.   Wine(int age);

d.   Wine(int newAge, float newCost);

16.    Given the following class and object declaration, how would you print out the age and cost of a bottle of wine?

class Wine

{

public:

Wine();

int getAge();

float getCost();

private:

int age;

float cost;

}

Wine bottle;

a.   cout

b.   cout

c.   cout

d.   cout

17.    Data members or member functions of a class that are declared to be private may:

a.   only be accessed by the main program.

b.   only be accessed by members of the class.

c.   not be accessed by the class.

d.   are considered to be global variables.

18.    In a structure, all members are ____________ by default.

a.   public

b.   private

c.   global

d.   All of the choices apply.

19.    In a class, all members are ____________ by default.

a.   public

b.   private

c.   global

d.   All of the choices apply.

20.    The ifstream class is derived from the:

a.   ofstream class.

b.   istream class.

c.   iomanip class

d.   None of the choices apply.

21.    A structure variable is declared differently from a predefined type such as an int.

a.   True

b.   False

22.    Two different structure definitions may have the same member names.

a.   True

b.   False

23.    A structure can only be passed to a function as a call-by-value parameter.

a.   True

b.   False

24.    A function may return a structure.

a.   True

b.   False

25.    Different class may not have member functions with the same name.

a.   True

b.   False

26.    A class member function may be private.

a.   True

b.   False

27.    Class data members are almost always public.

a.   True

b.   False

28.    It is possible to have multiple private labels in a class definition.

a.   True

b.   False

29.    The assignment operator may not be used with objects of a class.

a.   True

b.   False

30.    All constructors for a class must be private.

a.   True

b.   False

"Get 15% discount on your first 3 orders with us"
Use the following coupon
FIRST15

Order Now