mode 1 Flashcards
What is an array?
It’s a series of data entries (of the same datatype). Sequential in memory. Also, you can’t change the size of an array. (You could also describe it as a “group” or “matrix”, but NOT a list, set or collection)
How do I create an array?
int[] arry1 = new int[95]; //95 elements in this array
int[] arry2 = {5, 7, 19}; //3 elements in this array
int arry3[] = {1, 66, 120, 5};
int arry4[]= new int[]{4,1,5};
What happens when I take a look at an uninitialized element?
We see the default values of the give datatype:
int is 0,
double is 0.0D,
float is 0.0F,
short is 0, long is 0L, boolean is false, byte is 0, char is “empty character”,
Objects of any type default to “null”
WHAT is the heap?
The heap is the allowable memory space your operating systems gives you for your program’s runtime
WHAT is the stack?
The stack is a structured memory space inside of the heap used to keep track of the program’s order of operations (the flow of execution).. It’ll contain things like method calls, local variables, etc (NOT object and arrays)
>a stack is last in first out (LIFO) aka first in last out (FILO)
>a stack is like a stack of pancakes, the last pancake you put on your plate is also the first pancake you eat
> Use case: for a stack, you may want to use a stack if you’re creating an “undo” and “redo” functionality
What….is the counterpart to a stack?
Queue is the counterpart of a stack.
>a queue is first in first out (FIFO) or (LILO)
>a queue is like the line at the DMV, when you’re first in line you’re also the first to be serviced
> Use case: for a queue, you may want to use a queue if you’re keeping track of some transactions in an application
What is a data structure?
A data structure is an object in programming that is designed to store a large group of data entries.
>
>for example, there are: linked lists, array lists, binary trees, maps, etc.
Why do we use data structures
We use data structures to create efficiency and organization in storing large groups of data entries. It’s like having your toys scattered around your room OR having a toy box.
>there are MANY different types of data structures out there (and you can even invent more if you’d like); each with their own pros and cons.
What are modifiers?
A keyword used to modify the functionality of the method (not just the access level, like most initial think)
Types of modifiers?
public, protected, private, static, final, default, synchronized, transient, abstract, etc
What is wrong with redundant code?
Maintainability issue: the code has far more lines than necessary, the code is bloated and takes more time to update the code base
Readability issue: promotes update anomalies aka if you accidentally miss one (or more) of the updates
What is modularization?
Modularization is how we defeat redundancy
The process of creating a module of reusable functionality. for example, creating a method out of functionality instead of copying and pasting