OOP Final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Consider the class inheritance. class B{ public:B();B(int nn);void f();void g();private:int n;}; class D: public B{ public:D(int nn, double dd);void h();private:double d;}; How many private members does an object of class D have?

2

Given the following 2D array definition: int matrix[2][3]; It will create an array of size:

2 by 3

Which of the following are the correct preprocessor commands necessary to prevent multiple inclusions of header files? 1.#include "header.h" 2.#define HEADER_H #ifndef HEADER_H//declarations for header.h go here#endif 3.#ifndef HEADER_H#define HEADER_H// declarations for header.h go here#endif 4.#ifndef HEADER_H//declarations for header.h go here#endif Which of the above is the correct answer.

3

Consider the class inheritance. class B{ public:B();B(int nn);void f();void g();private:int n;}; class D: public B{ public:D(int nn, double dd);void h();private:double d;}; How many public members does an object of class D have?

4

Given the following array declaration: int x[] = {8, 7, 6, 5, 4}; What is the value of x[2]?

6

Given the following array declaration: int x[10] = {8, 7, 6, 5, 4}; What is the value of x[9]?

9

Which of these array definitions will set all the indexed variables to 0? a.int array[5] = {0}; b.int array[5] = {0,0,0} c.int array[5] = {0,0,0,0,0};

All of the above

If a class B is a base class for a derived class D, then an object of class D bears what relationship to class B?

An is-a relationship

A C++ structure, or struct, like the C++ array, is a homogeneous data structure. (i.e., all data is of the same type)

False

A class that has a pure virtual member function is called a concrete base class. 1.

False

A constructor is always named construct with class name attached. If the class is Foo, then the constructor name is constructFoo.

False

A constructor is like a function. It can return any type value needed.

False

A friend function has access only to the private members only.

False

A function can return an array.

False

An input stream is a stream of data flowing from your program, either to a file, or to the keyboard.

False

Assignment behaves essentially the same for vectors as for arrays.

False

Constructors are inherited. After all something has to initialize the inherited variables.

False

Dangling pointers present no problem in C++

False

If a base class constructor is not called explicitly in the definition of a derived class constructor, an error results.

False

In a class, functions declared with the virtual keyword need not be defined.

False

Late binding refers to a failure to secure one's ski boots.

False

One can use the & operator to extract the value that a pointer points to.

False

Pointer variables are just memory addresses and can be assigned to one another without regard to type.

False

The declaration below declares three pointer variables of type pointer to double that is, a pointer of type (double*) double* p1, p2, p3;

False

The default copy constructor and default operator = provide deep copy.

False

You can change the behavior of + for the int type using operator overloading.

False

size and capacity of a vector are two names for the same thing.

False

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

Inheritance

If we delete the memory pointed to by a pointer then we must also set pointer to:

NULL

A member of a structure or of a class is accessed using the

The dot operator

You have a program with a class that is separated into files. The implementation has been changed. Of the interface file, the implementation file and the application file, which must be recompiled?

The implementation file

A C-String is an array with base type char and ends with a null character (0).

True

A class can have friends that are functions as well as friend classes.

True

A constructor is a special kind of member function. It is automatically called when an object of that class is declared.

True

A pointer is a variable that holds the address of some other location in memory.

True

A pointer is an address, an address is an integer, but a pointer is not an integer.

True

A static function can only access static data.

True

A static member can be called with reference to the class name as: ClassName.StaticFunctionName();

True

A stream is a flow of data into or out of your program.

True

An array name is a constant pointer to array base type.

True

An output stream is a stream of data flowing from your program, to a file, a device of some sort such as the screen.

True

Dynamic variables or dynamically allocated variables in C++ are created and destroyed according to the program's needs.

True

Future "new" operations will fail if freestore is "full"

True

Heap is also called freestore.

True

If I need to build an object for return from a function, I can construct that function directly in the return statement.

True

If class D is derived from class B, we speak of D as the child class and B as the parent class.

True

In C++ Arrays are always passed by reference.

True

It is legal to have all member functions of a class be pure virtual functions.

True

Local variables are declared within a function and are destroyed when function call is completed.

True

No objects can be defined of abstract base class type since it is an incomplete definition.

True

Only member functions can be virtual.

True

Overloading a binary operator as a stand-alone function requires two arguments.

True

Structure definitions are usually global (defined outside any functions).

True

The concept of class is central to Object Oriented Programming.

True

The flush member function copies the file buffer to the file on the file medium.

True

The functions or data members declared in the private: section of a class can be accessed only in the definition of functions declared in that class.

True

The include statement, #include "file.h" looks in the system defined directory for the file.h.

True

There should eventually be a call to the operator delete on a pointer that points to the memory allocated by each call to new.

True

Virtual functions allow old code to call new code.

True

When declaring several pointer variables, there must be one pointer declarator * for each pointer variable.

True

When overloading an operator, you can create a new operator different from the more usual operators.

True

When overloading an operator, you cannot change the number of arguments an operator takes.

True

When you use the open member function to tie a file name to a file stream, the file name is called the external file name, and the program refers to the file by the stream name.

True

When you write: ifstream inStream;inStream.open("infile.dat"); The file, infile.dat must be located in the directory where the program is being run.

True

at(i) function returns reference to char at position i;

True

length() function returns the length of the string.

True

stoi function can be used to convert a numerical string into an integer.

True

Given the following array declaration: int x[] = {8, 7, 6, 5, 4}; What is the value of x[5]?

Undefined

A class member that is to be shared among all objects of a class is called

a static member

C++ allows the programmer to deal with data at a higher level of abstraction in part because related data of differing types can be treated as a unit in

a structure variable

Which of the following can be virtual?1. Constructors

a. Destructors b. Ordinary functions

A pure virtual function is a member function

a. Whose declaration ends with = 0. b. Member form that is used to force all derived classes to implement that member function or be a pure virtual function member of the derived class.

Some pointer arithmetic is allowed. Which of the following arithmetic operators is allowed (Select all that applies)?

a. pointer + integer b. pointer-- c. pointer++

A program decides after it begins to run what function to execute in response to a statement such as refToObject.func()is an example of:

a. polymorphism b. late binding c. virtual functions

Given the array declaration, int a[20]; The first element is written as:

a[0]

Given the array declaration, int a[20]; The last element is written as:

a[19]

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 { };

The ____________ fstream member function closes a file stream.

close ( )

The ____________ fstream member function to detect the end of input file.

eof ( )

To determine whether a file was opened successfully, one can use the ___________ fstream member function

fail ()

Which of the following is the name of an interface file

file.h

What keyword is added to member function declaration to prevent it from being overridden in a child class?

final

I want to have a nonmember function to have access to the private members of a class. The class must declare that function a

friend

What is the output of the following code (assuming it is embedded in a correct and complete program)? char letter[5] = {'o', 'k', 'c', 'e', 'g'}; for(int i = 4; i >= 0; i-- ) { cout << letter[i];} cout << endl;

gecko

You must use_____function to read a string with blank spaces:

getline

There are several uses of the getline function. Assume the definition, string line; Which one of these allows specification of the character on which input stop?

getline(cin, line);

Overloaded operator >>, when used as an input, returns an

istream&

Consider the function definition and array declarations. Which is the correct calls to the function make_2? void make_2 ( int a[], int size ){for (int i = 0; i < size; i++ )a[i] = 2;}int array1[20];

make_2( array1, 20 );

A UML diagram does not contain:

object name

Most programming languages that are in use today are:

object-oriented

The ____________ fstream member function opens a file stream and connects the stream variable to a physical file whose name is the argument to the function.

open ( )

Overloaded operator <<, when used as an output, returns an

ostream&

Given the class declaration, class D : public class B {/*...*/}; Which of the following is true?

private members of B become public members of D

Constructor of a class must be declared in section of the class.

public

The header file that you must #include to have access to the Standard Library string class is:

string

What does the following UML diagram entry mean? - height:double

this is a private variable named hight and is a double data type

What does the following UML diagram entry mean? + setHeight(h : double) : void

this is a public function with a parameter of data type double and does not return a value

Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java by:

using the private access specifier on the class variables

Class objects normally have __________ that perform useful operations on their data, but primitive variables do not.

variables

If a class is named MyClass, what must the destructor be named?

~MyClass


संबंधित स्टडी सेट्स

ISYS 2263 Exam 2 Practice Questions

View Set

Chapter 14: Marketing Channels Key Concepts/Notes

View Set

ASE A1 (Engine Repair) Practice Test - Cumulative

View Set

Clicker Questions exam 3 physics

View Set