Module 6: Introduction to Object- Oriented Programming Flashcards

1
Q

What is a data structure?

A

It is “any of various methods or formats (as an array, file, or record) for organizing data in a computer”.

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

What are considered simple data structures?

A

Arrays, Lists, Queues, Stacks

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

What are complex data structures?

A

Complex data structures are those in which data and behaviors are encapsulated in the same component and they are considered to be a logical unit independent of another component.

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

What are the two types of complex data structures?

A

Structs and Classes.

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

What is a struct and what is it used for?

A

A value type. The ability to represent a complex data structure in a lightweight type is primarily what a struct is used for. Lightweight refers to the amount of processing and memory necessary to deal with structs when compared to classes.

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

What is a class?

A

They contain data and functionality. They are reference types and are allocated on the heap. They use constructors to initialize instance variables. For you to use a class in your code, you must create an instance of that class.

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

What is a value type?

A

Value types are stored on the stack and typically passed as a copy or by value. Reference types are instantiated, or created, on the heap and they are passed by reference.

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

What can structs contain?

A

Data in the form of member variables, a constructor, other methods.
Member variables cannot be initialized in the body of a struct.
Constructors without parameters are not permitted.

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

What limitations do structs have compared to a class?

A

You cannot implement inheritance with structs. Also, structs are passed by value, which means that if you have a large struct in your code and if you pass that between methods, the entire struct is passed on the stack. This can generate out-of-memory errors in case the stack becomes full.

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

What are static classes?

A

Static classes are used to represent functionality without creating an object. Any class that is declared as a static class cannot be instantiated in code.

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

What is instaciation?

A

By instantiating a class, you can create multiple instances of that class in code. An instance of a class in your code is known as an object. Objects contain data that is specific to an instance and not data that can be shared.

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