OOP Final

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which of the following operators may be used to assign one object to another?

=

Select all that apply. Given the following code fragment, which of the things shown below happen when the statement on line 8 executes? 1 int square(int a)2 {3 return a * a;4 }5 int main()6 {7 int x = 0;8 x = square(5);9 cout << x << endl;10 return 0;11 }a. The square function is called and the value 5 is passed as an argument.b. The square function calculates 5*5 and stores the result, 25, as a temporary value.c. The temporary value is copied (assigned) to the variable x.d. The temporary value is discarded by the system.e. None of these

A,B,C,D

If you do NOT furnish a ________, a default one will be provided by the compiler.

All of these

A destructor function can have none, one, or more parameters.

False

A member function of a derived class may not have the same name as a member function of a base class.

False

A non-static member function may not access a static member variable.

False

A public data member may be declared a friend of a private function.

False

C++ permits you to overload the sizeof operator and the this pointer.

False

If you overload the prefix ++ operator, the postfix ++ operator is automatically overloaded.

False

In C++ if you overload the < operator, you must also overload the > operator.

False

In C++11, using constructor inheritance, it is possible for any of the base class's constructors to be inherited.

False

In an inheritance situation, you may not pass arguments to a base class constructor.

False

In-place member initialization is not available in C++11. We could only perform in-class initialization on static const members of integral or enumeration type.

False

The overloaded = operator copies data from one object to another so it is known as the overload copy operator.

False

When a class declares an entire class as its friend, the friendship status is reciprocal. That is, each class's member functions have free access to the other's private members.

False

When you overload the << operator you must also overload the >> operator.

False

You can overload the conditional operator to make it function as an unconditional operator.

False

You may overload any C++ operator and you may use the operator function to define non-standard operations, such as @ or ^.

False

You must use the private access specification for all data members of a class.

False

Arguments are passed to the base class by the ________ class ________ function.

None of these

Arguments are passed to the base class destructor by the ________ class ________ function.

None of these

The following statement allows the ________ members of the Car class to access ________ members of the Vehicle class. class Car : public Vehicle private, private public, private protected, private public, protected

None of these

When more than one class is derived from a base class, the situation is called

None of these

A derived class may become a base class if another class is derived from it.

True

A private member function is useful for tasks that are internal to the class but it is not directly called by statements outside the class.

True

A static member function does not need to be called by a specific object of the class.

True

A static member variable can be used when there are no objects of the class in existence.

True

An aggregate class's constructor can use a member initialization list to call the constructors for each of its member objects.

True

By default, when an object is assigned to another object, each member of one object is copied to its counterpart in the other object.

True

C++11 provides a way for a derived class to inherit some of the base class's constructors.

True

In C++11 an rvalue reference is a reference variable that can refer only to temporary objects.

True

It is possible to declare an entire class as a friend of another class.

True

Pointers to a base class may be assigned the address of a derived class object.

True

Static binding occurs when the compiler binds a function call with the function call that resides in the same class as the call itself.

True

The base class access specification can be viewed as a filter that base class members must pass through when becoming inherited members of a derived class.

True

The this pointer is a special built-in pointer that is automatically passed as a hidden argument to all non-static member functions.

True

When arguments must be passed to the base class constructor, they are passed from the derived class constructor's header line.

True

When you overload an operator, you can change the operator's original meaning to something entirely different.

True

You can use the technique known as a member initialization list to initialize members of a class.

True

Select all that apply. Which of the following constructors cannot be inherited through constructor inheritance? the default constructor the virtual constructor the move constructor the copy constructor the grand constructor

a,b,d

The base class's ________ affects the way its members are inherited by the derived class.

access specification

Multiple inheritance opens the opportunity for a derived class to have ________ members.

ambiguous

In OOP terminology, an object's member variables are often called its ________ and its member functions can be referred to as its behaviors or its ________.

attributes, methods

What is being protected in the following statement? class Car : protected Vehicle

base class members

The ________ constructor is called before the ________ constructor.

base, derived

Which is the derived class in the following statement? class Car : protected Vehicle

car

It is a good idea to make a copy constructor's parameters ________ by specifying the ________ key word in the parameter list.

constant, const

A ________ is a member function that is automatically called when a class object is ________.

constructor, created

A(n) ________ is a special function that is called whenever a new object is created and initialized with another object's data.

copy constructor

When objects contain pointers, it is a good idea to create an explicit ________ function.

copy constructor

The ________ destructor is called before the ________ destructor.

derived, base

Select all that apply. In an inheritance situation, the new class that you create from an existing class is known as the derived class inheritor child class parental class None of these

derived, child

Multiple inheritance is when a ________ class has ________ base classes.

derived, two or more

In the following function header, the word int is known as a(n) ________.FeetInches FeetInches::operator++(int)

dummy parameter

The compiler performs ________ on virtual functions.

dynamic binding

A derived class may not have any classes derived from it.

false

A(n) ________ informs the compiler that a class will be declared later in the program.

forward declaration

Which type of function is NOT a member of a class but has access to the private members of the class?

friend

In OOP programming, ________ allows you to create new classes based on existing classes.

inheritance

Which of the following is commonly used to extend a class or to give it additional capabilities?

inheritance

When the body of a member function is defined inside a class declaration, it is said to be

inline

In C++11 values that persist beyond the statement that created them and have names that make them accessible to other statements in the program are called

lvalues

When you derive a class from an existing class, you ________ add new data and functions.

may

Polymorphism is when ________ in a class hierarchy perform differently, depending on which object performs the call.

member functions

Each object of a class has its own copy of the class's

member variables

In C++11 the ________ operator swaps the members of the object being assigned with the temporary object.

move assignment

When a derived class has two or more base classes, the situation is called

multiple inheritance

When a class contains an instance of another class, it is known as

object composition

When you overload an operator, you cannot change the number of ________ taken by the operator.

operands

To overload the + operator, you would write a function named

operator +

An ________ operator can work with programmer-defined data types.

overloaded

When you redefine the way a standard operator works when it is used with class objects, you have ________ the operator.

overloaded

If you do NOT furnish a(n) ________, an automatic memberwise copy will be performed when one object is assigned to another object.

overloaded assignment operator

A virtual function is a function that expects to be ________ in a derived class.

overridden

C++11 introduced the ________ key word to help prevent subtle errors when overriding virtual functions.

override

The term ________ means the ability to take many forms.

polymorphism

When member functions behave differently depending on which object performed the call, this is an example of

polymorphism

If you do NOT declare an access specification, the default for members of a class is

private

The ________ members of a base class are never accessible to a derived class.

private

Protected members of a base class are like ________, but they may be accessed by derived classes.

private members

Select all that apply. The base class access specification determines how ________ members in the base class may be accessed by derived classes.

private, public, protected

C++ requires that a copy constructor's parameter be a(n)

reference object

In C++11 reference variables that can refer only to temporary objects that would otherwise have no name are called ________ and are declared with a ________.

rvalues, double ampersand (&&)

A reason to overload the ________ is to allow you to write classes that have array-like behaviors.

square brackets [ ] operator

C++ allows you to redefine the way ________ work when used with class objects.

standard operators

A member function that is declared ________ may not access any non-static data members in the class.

static

If a member is declared ________, all objects of that class have access to that variable.

static

The ________ member variable may be accessed before any objects of the class have been created.

static

When the compiler binds a member function call with the version of the function that resides in the same class as the call itself, it is considered

static binding

A C++ class is similar to a(n)

structure

A(n) ________ is a special built-in pointer that is available to a class's member functions.

this pointer

A move operation transfers resources from a source object to a target object.

true

In C++11, if a derived class attempts to override a final member function, the compiler generates an error.

true

More than one class may be derived from a base class.

true

Which is the base class in the following statement? class Car : public Vehicle

vehicle

A virtual function is declared by placing the ________ key word in front of the return type in the base class's function declaration.

virtual

Functions that are dynamically bound by the compiler are ________ functions.

virtual

A ________ of a base class expects to be overridden in a derived class.

virtual function

A good reason to overload an operator is to enable it to

work in its usual way, but with programmer-defined data types

For the following code, which statement is NOT true? class Point { private: double y; double z; public: double x; }; x is available to code that is written outside the class. The name of the class is Point. x, y, and z are called members of the class. z is not available to code that is written outside the class. All of these are true.

z is not available to code that is written outside the class.


Kaugnay na mga set ng pag-aaral

NCLEX Style Practice Questions Burns, Med Surg - Burns NCLEX Review Questions, Med Surg Exam 3 Burns Questions, Med Surg : Chapter 25 Burns

View Set

Compensation Administration - Chapter 15 Questions

View Set

NUR379 Evolve: Pediatric Gastrointestinal System - Gastrointestinal Motility and Malabsorption Conditions

View Set

Civics Chapter 18 Goods & Services

View Set

Sugar Changed the World UNIT 3 TEST REVIEW

View Set

Succeeding in your online course

View Set