Module 6: Introduction to Object- Oriented Programming Flashcards
What is a data structure?
It is “any of various methods or formats (as an array, file, or record) for organizing data in a computer”.
What are considered simple data structures?
Arrays, Lists, Queues, Stacks
What are complex data structures?
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.
What are the two types of complex data structures?
Structs and Classes.
What is a struct and what is it used for?
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.
What is a class?
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.
What is a value type?
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.
What can structs contain?
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.
What limitations do structs have compared to a class?
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.
What are static classes?
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.
What is instaciation?
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.