COSC-1337 Chapter 7 Flashcards

1
Q

What is data abstraction?

A

It is the separation between knowing a data type’s logical properties from its implementation details.

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

What are the two common methods in programming today?

A

Procedural programming and object oriented programming.

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

What is an access specifier?

A

public: / private: - this determines if the member variable or function is publicly accessible or not.

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

How would you write the class “Circle” with one private member variable and two public member functions?

A

class Circle {

 private:
 double radius;
     public:
     void setRadius(double r) {
          radius = r;
     }
     double calcArea() {
          return 3.14*pow(radius, 2);
     }

};

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

Create two object of the class “Circle” named object1 and object2.

Then call the setRadius member function within the class circle with both object/s and pass arguments to them.

A

Circle object1, object2;

object1. setRadius(1.0);
object2. setRadius(2.5);

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

What is a member function that was created within a class declaration known as?

A

An “inline function”

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

What is a class member function called when it is defined outside of the class declaration?

A

Function implementation

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

How is a function implementation different than a regular function definition?

A

After you name the function return type, you must state the Class name, followed by a “double colon” “::”, followed by the name of the member function you are going to define, and then any parameters the member function may need.

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

Write the function implementation for the calArea member function from the class “Circle”

A

double Circle::calcArea() {

 return 3.14*pow(radius, 2); }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the “double colon” in a function implementation called?

A

Scope resolution operator.

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

Should you declare your Classes and member function implementations BEFORE the main function?

A

Yes, this is so that the entire program has access to it.

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

What is the special memory location that is used when a function implementation is called?

A

Stack

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

_____________ is a member function that is automatically called when the when a class object is created?

A

A “constructor”

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

A constructor that has no parameters is known as a?

A

“Default constructor”

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

Do constructors have a return value?

A

Never

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

Calling on a constructor inside the declaration of a constructor is called?

A

Constructor Delegation