Lecture 1 Notes Flashcards

1
Q

What is a program?

A

A list of instructions for a computer to execute.

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

What are Machine Languages?

A

Languages used by the computer, but difficult for humans to read.

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

What are assembly languages?

A

Symbolic translation of machine code which are easier for people to read (but still kind of hard)

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

What are high-level procedural languages (such as Pascal, Fortran, and C)?

A

More human-readable languages that can be converted into assembly language and then assembled into machine code.

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

What are Object-Oriented Languages (C++, Java, Smalltalk)?

A

Languages that encapsulate their data and procedures together in units called objects, which contain more than just functions. This makes the code more modular and readable to humans.

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

What is the C programming language?

A

A high-level procedural programming language.

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

What is the C++ language?

A

An object-oriented programming language based on the C programming language.

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

What is an object?

A

An encapsulation of data and functions that act upon that data.

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

What are the three aspects of an object?

A
  • Name – The variable name given to the object.
  • Attributes (member data) – The data that describes what the object is.
  • Behavior (member functions) – behavior aspects of the object, aka functions that describe what the object actually does.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a class?

A

A blueprint for objects.

A class is a user-defined type that describes what a certain type of object will look like. A class description consists of a declaration and a definition (usually split into separate files.)

An object is a single instance of a class.

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

What’s the difference between a class and a struct?

A

They are essentially the same but with one key difference:

Structs have all their data and functions public by default, whereas Classes are private by default.

As a side note: Struct is still important for use in C++ because it is backwards compatible with C (which does not have Classes, but does have Structs.) C Structs can NOT contain functions, but C++ Structs can, so that’s important to know.

The use of a Struct or Class in your code is largely down to your personal style or preference since they are essentially interchangeable as far as functionality.

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

What does DDU design stand for?

A

Declare, Define, Use

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

What is the Declare portion of DDU design?

A

A declaration gives an interface.

A variable declaration gives the type.

A function declaration tells how to use the function (without any specifics on what it does.)

A class declaration shows what an object will look like and what its available functions area.

Implementation details are not needed for declarations.

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

What is the Define portion of DDU design?

A

A definition usually consists of the implementation details. This isn’t necessary for the user of the interface to know. It’s essentially the code (or function body) of the function. A class definition consists of the definitions of its members.

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

What is the Use portion of DDU design?

A

The use of an item through its interface.

The user of a function is a programmer who makes calls to the function without needing to know its implementation details.

The user of a class is a programmer who uses the class by creating objects and calling the available functions for those objects.

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

What is the interface?

A

The interface is what the user sees.

The implementation details of the interface are often hidden in order to create a clear interface for the user, which is not necessarily the end user of a program. It could be a programmer, i.e. the user of a class.

17
Q

What does it mean when a member of a class has a public protection level?

A

The class member can be accessed from inside or outside of the object.

18
Q

What does it mean when a member of a class has a private protection level?

A

The class member can only be used by the object itself.

19
Q

What is the standard practice for protection level of a class’ member data?

A

Private

20
Q

What are the 4 reasons for making data private (data hiding)?

A
  1. Makes the interface simpler for the user.
  2. Principle of least privilege (need-to-know)
  3. More secure. Less chance for misuse (accidental or malicious)
  4. Class implementation is easy to change without affecting other modules that use it.
21
Q

What is the declaration format for a class?

A

class className
{
public:

private:
};

22
Q
A