Midterm Flashcards

1
Q

What is the output?

typedef long sqfeet;
sqfeet area = 3500;
cout<

A

Answer: 4

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

What is the output?

int foo[6] = {12, 2, 1, 30, 4, 7}; cout<

A

Answer: 30

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

What is the output?

char ch[]=”Dalhousie”;
char * pch_ptr = ch;
cout<

A

Answer: D

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

What is the output?

class Box{ Box(){
         cout << "Box created!\n";
      }
      ~Box(){
         cout << "Box destroyed!\n";
} };
   void main( ){
      Box* myBoxArray = new Box[2];
}
A

Answer:
Box created!
Box created!

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

What is the output?

enum Suit { Diamonds = 5,
      Hearts,
      Clubs,
      Spades = 2 };
   cout << Suit::Clubs;
A

Answer: 7

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

What is the output?

template
T multiply( S i_var1, T i_var2) {
  return i_var1 * i_var2;
}
void main(){
  float pi = 3.14;
  int val = 2.0;
  cout << multiply(val, pi);
}
A

Answer: 6.28

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

What is the output?

class People {
 public:
  virtual void Out() { cout << "We are People\n"; }
};
class GoodPeople : public People {
  public:
    void Out() { cout << "We are Good\n"; }
  };
}
void main(){
  People * we = new GoodPeople();
  we->Out();
}
A

Answer:

We are Good

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

People * we = new GoodPeople();

For the code segment shown above, what is the actual type and the declared type of the variable “we”?

A

Actual type = pointer to GoodPeople

Declared type = pointer to People

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

Members of a class are _________ by default, while members of a struct are _________ by default

A

private

public

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

In object oriented design, _________ is represented by a has-a relationship, while _________ is represented by “is-a” relationship

A

aggregation

inheritance/generalization

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

Study the code below and identify the type of match (exact match, ambiguous match or promotion) that will result from each call to func

void Func(int value) { cout << value; }
void Func(float value) { cout << value; }
void main(){
   Func('a');
   Func(0);
   Func(3.14159);
}
A

1 promotion

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

Identify the type and value of the variable z

int x = 10;
int * y = &x;
int z = *y;

A
//Type of variable z = int
//Value of variable z = 10
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A struct can contain structs as members. (T/F)

A

True

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

Static variables are global variables, with memory allocated on the Stack. (T/F)

A

False

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

If CAR is a class, CAR * myCar = new CAR creates a CAR object on the Heap (T/F)

A

True

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

A reflexive association is when a class is associated with itself. (T/F)

A

True

17
Q

Use case diagrams represent the static view of a system. (T/F)

A

False

18
Q

If no constructors are specified for a derived class, objects of the derived class will use the constructors in the base class.(T/F)

A

True

19
Q

To be accessed from a member function of the derived class, data or functions in the base class must be public or _________ . (Protected, Private, Const, Extern)

A

Protected

20
Q

In requirements descriptions, the nouns and noun phrases normally represent ___________ (classes, methods, variables, relations)

A

Classes

21
Q

_______________ is not an essential element of an object oriented model (Modularity, Hierarchy, Encapsulation, Overloading)

A

Overloading

22
Q

In an object oriented design, the static view of a complex system is represented by ________ (use case diagrams, inheritance, class diagrams, encapsulation)

A

class diagrams