CS116

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is the syntax of creating Inheritance in C++? class <child class name> extends <parent class name> class <child class name>: <parent class name> access specifier class <child class name>: <parent class name> Correct! class <child class name>: access specifier <parent class name>

Correct Answer class <child class name> extends <parent class name> class <child class name>: <parent class name> access specifier class <child class name>: <parent class name> Correct! class <child class name>: access specifier <parent class name>

The ability to reuse objects already defined, perhaps for a different purpose, with modification appropriate to the new purpose, is referred to as: inheritance information hiding overloading redefinition

Correct Answer inheritance information hiding overloading redefinition

Which is the derived class in the following statement?class Car : protected Vehicle Car None of these protected Vehicle There is no way to tell.

Correct! Car None of these protected Vehicle There is no way to tell.

Which of the following is a benefit of encapsulation? It allows a function defined in one class to be reused in another class. It improves the performance of an application. It guarantees that an object cannot be accidentally put into an inconsistent state. It prevents functions that are internal to a class from changing private data members.

Correct! It allows a function defined in one class to be reused in another class. It improves the performance of an application. It guarantees that an object cannot be accidentally put into an inconsistent state. It prevents functions that are internal to a class from changing private data members.

The base class's ________ affects the way its members are inherited by the derived class. access specification construction None of these return data type name

Correct! access specification construction None of these return data type name

What is being protected in the following statement?class Car : protected Vehicle base class members derived class functions None of these future inherited classes derived class data

Correct! base class members derived class functions None of these future inherited classes derived class data

Which of the following is correct syntax to declare C++ class B to be a public base class for derived class D? class D : public B {/* ... */}; class B: public D { }; class D : public class B {/* ... */}; none of the above public base class B: class D {/*...*/};

Correct! class D : public B {/* ... */}; class B: public D { }; class D : public class B {/* ... */}; none of the above public base class B: class D {/*...*/};

class object member function that modify class object data members is call _________ function. mutator private method accesor

Correct! mutator private method accesor

Which one is the best way to define vector pointers of class object Person? vector<Person *> PersonList; vector<*> Person; Person vector<* Person> ; vector<Person > * PersonList;

Correct! vector<Person *> PersonList; vector<*> Person; Person vector<* Person> ; vector<Person > * PersonList;

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

FALSE

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

False

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

False

The ________ destructor is called before the ________ destructor. None of these base, derived derived, base public, private private, public

None of these base, derived Correct! derived, base public, private private, public

A ________ of a base class expects to be overridden in a derived class. None of these destructor function static function constructor function virtual function

None of these destructor function static function constructor function Correct! virtual function

When a derived class has two or more base classes, the situation is called None of these multiplicity polymorphism multiple inheritance encapsulation

None of these multiplicity polymorphism Correct! multiple inheritance encapsulation

When you derive a class from an existing class, you ________ add new data and functions. None of these must never may

None of these must never Correct! may

To overload the + operator, you would write a function named None of these overload + operator + function + operator.overload(+)

None of these overload + Correct! operator + function + operator.overload(+)

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

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

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

TRUE

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

True

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

True

What is the output of the code snippet below? int foo() { int *iPtr; *iPtrs = 8; cout<<*iPtr; } address of iPtr variable 8 address of 8 Correct! Segmentation fault

address of iPtr variable 8 address of 8 Correct! Segmentation fault

Arguments are passed to the base class destructor by the ________ class ________ function. base, destructor derived, destructor None of these base, constructor derived, constructor

base, destructor derived, destructor Correct Answer None of these base, constructor derived, constructor

Protected members of a base class are like ________, but they may be accessed by derived classes. constructor functions None of these static members public members private members

constructor functions None of these static members public members Correct! private members

The ________ constructor is called before the ________ constructor. derived, base None of these base, derived private, public public, private

derived, base None of these Correct! base, derived private, public public, private

Arguments are passed to the base class by the ________ class ________ function. derived, constructor base, destructor base, constructor derived, destructor None of these

derived, constructor base, destructor base, constructor derived, destructor Correct! None of these

Which type of function is NOT a member of a class but has access to the private members of the class? destructor friend constructor static None of these

destructor Correct! friend constructor static None of these

When more than one class is derived from a base class, the situation is called encapsulation population polymorphism None of these multiplicity

encapsulation population polymorphism Correct! None of these multiplicity

In OOP programming, ________ allows you to create new classes based on existing classes. function overloading polymorphism inheritance the copy constructor None of these

function overloading polymorphism Correct! inheritance the copy constructor None of these

Multiple inheritance opens the opportunity for a derived class to have ________ members. private public ambiguous None of these dynamic

private public Correct! ambiguous None of these dynamic

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

private, private public, protected protected, private public, private Correct! None of these

The ________ members of a base class are never accessible to a derived class. public All of these None of these protected private

public All of these None of these protected Correct! private

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

public class None of these Car Correct! Vehicle

What is the output of the following program? #include <iostream> using namespace std; class TestClass { private: int val; void showVal() {cout<<val<<endl;} public: TestClass(int x) {val = x;} }; int main () { TestClass test(77); test.showVal(); return 0; }

the program runs but there is no output. 0 77 Correct! the program will not compile

What is the output of the code snippet below? int foo() { int i, x, y; i = 8; x = i++; x+= ++i; y = x + i; cout<< y; } 10 28 27 18 26

10 Correct! 28 27 18 26

which one of below is to get current date and time as part of ctime library? time_t now = time(0); time_t now = getCurrentTime(0); time_t now = time(now); time_t now = getDateTime(0);

Correct! time_t now = time(0); time_t now = getCurrentTime(0); time_t now = time(now); time_t now = getDateTime(0);

What is the output of the code snippet below: look at code from exam 2 Q31 1 1 Correct Answer 2 3 4 4 3 2 1 2 2 3 1 3 2 1 1 2 3 None of these

1 1 Correct Answer 2 3 4 4 3 2 1 2 2 3 1 3 2 1 1 2 3 None of these


Ensembles d'études connexes

NAT 503 Final Study Guide Questions

View Set

Regents Chemistry (High School): What is the pH scale?

View Set

Chemistry Chapter 12: Stoichiometry

View Set

ITSE-1345 - Topic Quiz - Oracle PL/SQL Overview -1

View Set