Midterm Flashcards Preview

CSCI 3132 > Midterm > Flashcards

Flashcards in Midterm Deck (22)
Loading flashcards...
1
Q

What is the output?

typedef long sqfeet;
sqfeet area = 3500;
cout<

A

Answer: 4

2
Q

What is the output?

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

A

Answer: 30

3
Q

What is the output?

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

A

Answer: D

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!

5
Q

What is the output?

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

Answer: 7

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

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

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

9
Q

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

A

private

public

10
Q

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

A

aggregation

inheritance/generalization

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
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
13
Q

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

A

True

14
Q

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

A

False

15
Q

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

A

True

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