Midterm 1 Flashcards

1
Q

What value will the function eof return if there are more characters to be read in the input stream?

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

It is possible for a structure variable to be a member of another structure variable.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What will inFile.fail( ) return if the file associated with the stream inFile cannot be opened?

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The data members of a class are usually placed in the private section of a class.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The expression s->m; indicates that s is a structure pointer and m is a structure member.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If the implementation of a member function calls another member function, you do not need to use dot notation.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

A constructor cannot specify a return type.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The implementation of the member functions cannot access the private section of the class.

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Object-oriented design first identifies the objects required in a problem.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

q In object-oriented design, it is considered a correct procedure to implement a little, then test.

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. When passing a file stream object to a function, you should always pass it by reference.
A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. You must use the private access specification for all data members of a class.
A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. By default, when an object is assigned to another, each member of one object is copied to its counterpart in the other object.
A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A class may have this many default constructor(s).

A

at most one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which of the following assigns a value to the hourlyWage member of employee[2]

A

employee[2].hourlyWage = 100.00;

17
Q

Passing a structure as a constant reference parameter to a function does this

A

guarantees not to result in changes to the structure’s members

18
Q

This data type can be used to create files and write information to them but cannot be used to read information from them.

19
Q

Class type declarations (the class interface) are usually stored here

A

in their own header files

20
Q

A class is a(n) ________ that is defined by the programmer

21
Q

If the compiler encounters the line #ifndef BUTTON_H

A

go to the next line

22
Q

Which is the best prototype for a member function of a person class that returns true if the person object’s age is greater than that of another person object. Assume that age is a data member of the person class.

A

bool isOlderThan (const person &p) const;

23
Q

The first line of the implementation file time.cpp for a class called Time could be

A

include “time.h”

24
Q

What is the code that associates the input file stream inf with the file myFile.txt?

A
#define aFile “myFile.txt” ...ifstream inf;
     inf.open (aFile);
25
In the header file of a person class, which of the following is the default constructor?
person ();
26
A function that retrieves the value of a data member is called a(n):
accessor
27
If menu_button is an object of a class called button with a member function called get_color which has no parameters, a correct function call is:
menu_button.get_color( )
28
The word const after the end of a member function’s heading means
the function cannot change the data members
29
To pass an object of class person to a function as a formal value parameter most efficiently you should use:
const person&p
30
If a pointer p points to a struct type variable of type car which has fields make, model and year, which of the following is a correct way to reference the model.
(*p).model
31
What is true about the following statement?
If the file already exists, its contents are preserved and all output is written to the end of the file.
32
A header file is typically given the filename extension:
.h
33
This is a special function that is called whenever a new object is created and initialized with another object's data.
copy constructor
34
The assignment operator (=) can be used to:
Copy data from one object to another.
35
The compiler will implicitly create a default constructor if:
The class does not define any constructors.
36
Which of the following statements is not true of a constructor and destructor of the same class?
They both are able to have default arguments.
37
If Americans are objects of the same class, which of the following attributes would most likely be represented by a static variable of that class?
something similar that carries over across all of them