Skip to content

PR to update fork #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 123 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
17803e5
Create weel-three.md
ruthrootz Jan 31, 2022
d110b2b
Update README.md
ruthrootz Jan 31, 2022
85bedfa
name change
ruthrootz Jan 31, 2022
2c071ee
e
ruthrootz Feb 1, 2022
6214361
e
ruthrootz Feb 1, 2022
3e1d1c3
e
ruthrootz Feb 1, 2022
23addca
e
ruthrootz Feb 1, 2022
6633ca0
e
ruthrootz Feb 1, 2022
d5248b7
e
ruthrootz Feb 1, 2022
7554fd1
e
ruthrootz Feb 1, 2022
3fe1202
e
ruthrootz Feb 1, 2022
b0755aa
e
ruthrootz Feb 1, 2022
34e69fd
e
ruthrootz Feb 1, 2022
6ced0a8
Add files via upload
ruthrootz Feb 1, 2022
b2fead2
e
ruthrootz Feb 1, 2022
ff0632f
e
ruthrootz Feb 1, 2022
6868e80
e
ruthrootz Feb 1, 2022
6a1232c
e
ruthrootz Feb 1, 2022
b9b59af
e
ruthrootz Feb 5, 2022
6077345
e
ruthrootz Feb 5, 2022
e8ac6ad
e
ruthrootz Feb 5, 2022
398f338
e
ruthrootz Feb 5, 2022
24d8444
e
ruthrootz Feb 5, 2022
8ef8257
e
ruthrootz Feb 5, 2022
ca5490e
e
ruthrootz Feb 5, 2022
f0f62be
e
ruthrootz Feb 5, 2022
646f3da
e
ruthrootz Feb 5, 2022
b12b75d
e
ruthrootz Feb 9, 2022
0d006b7
e
ruthrootz Feb 9, 2022
83439b6
e
ruthrootz Feb 9, 2022
583101d
e
ruthrootz Feb 10, 2022
e5ef9b2
e
ruthrootz Feb 10, 2022
af3c65e
e
ruthrootz Feb 10, 2022
245c060
e
ruthrootz Feb 10, 2022
9d51269
e
ruthrootz Feb 10, 2022
fdcaa68
e
ruthrootz Feb 10, 2022
9e312b7
e
ruthrootz Feb 10, 2022
d630eac
e
ruthrootz Feb 10, 2022
8a59814
e
ruthrootz Feb 10, 2022
8a1ff4d
e
ruthrootz Feb 10, 2022
2ed6b7a
e
ruthrootz Feb 10, 2022
9865ab2
e
ruthrootz Feb 10, 2022
fcab9ee
e
ruthrootz Feb 10, 2022
3a54797
e
ruthrootz Feb 10, 2022
efe7fd9
e
ruthrootz Feb 10, 2022
818226e
e
ruthrootz Feb 12, 2022
d3bbb96
e
ruthrootz Feb 12, 2022
cd1c51c
e
ruthrootz Feb 12, 2022
abc68c4
e
ruthrootz Feb 12, 2022
7a69c8d
e
ruthrootz Feb 12, 2022
40ba80d
e
ruthrootz Feb 12, 2022
6817746
e
ruthrootz Feb 12, 2022
86c8c28
e
ruthrootz Feb 12, 2022
07a6838
e
ruthrootz Feb 19, 2022
8b12e2f
e
ruthrootz Feb 19, 2022
4a55279
e
ruthrootz Feb 19, 2022
16d5d8c
e
ruthrootz Feb 19, 2022
249a0ec
e
ruthrootz Feb 19, 2022
b483372
e
ruthrootz Feb 19, 2022
a25542e
e
ruthrootz Feb 19, 2022
9c59646
e
ruthrootz Feb 19, 2022
8a38019
e
ruthrootz Feb 19, 2022
1f8ec89
e
ruthrootz Feb 19, 2022
2b169d4
e
ruthrootz Feb 19, 2022
7cf3195
e
ruthrootz Feb 19, 2022
38b07c3
e
ruthrootz Feb 19, 2022
48ba8c4
e
ruthrootz Feb 19, 2022
b02fbbf
e
ruthrootz Feb 28, 2022
a4344c0
e
ruthrootz Mar 5, 2022
373b619
e
ruthrootz Mar 5, 2022
1f7169b
Update week-seven.md
ruthrootz Mar 7, 2022
987ad2b
Update week-seven.md
ruthrootz Mar 7, 2022
37f783d
Update week-seven.md
ruthrootz Mar 7, 2022
070a833
e
ruthrootz Mar 9, 2022
07747b1
e
ruthrootz Mar 9, 2022
1058c0f
e
ruthrootz Mar 23, 2022
1fd8cf7
e
ruthrootz Mar 23, 2022
33e30b9
e
ruthrootz Mar 23, 2022
b6f6c52
e
ruthrootz Mar 24, 2022
dd91fa4
e
ruthrootz Mar 24, 2022
e548a39
e
ruthrootz Mar 24, 2022
48a3dea
e
ruthrootz Mar 24, 2022
16ebf40
e
ruthrootz Mar 24, 2022
f34af21
e
ruthrootz Mar 24, 2022
3525a31
e
ruthrootz Mar 24, 2022
7f32c7e
e
ruthrootz Mar 24, 2022
f1783c4
e
ruthrootz Mar 26, 2022
be06ee6
e
ruthrootz Mar 26, 2022
e82ccef
e
ruthrootz Mar 26, 2022
e704426
e
ruthrootz Mar 26, 2022
8d64219
e
ruthrootz Mar 26, 2022
7319316
e
ruthrootz Mar 26, 2022
942d39e
e
ruthrootz Mar 26, 2022
a0d1363
e
ruthrootz Mar 26, 2022
bb2e41a
e
ruthrootz Mar 30, 2022
0089343
e
ruthrootz Mar 30, 2022
75538b4
e
ruthrootz Mar 30, 2022
426ed02
e
ruthrootz Mar 30, 2022
a6166c5
e
ruthrootz Mar 30, 2022
76d950f
e
ruthrootz Mar 30, 2022
9d408e1
e
ruthrootz Mar 30, 2022
83200be
e
ruthrootz Apr 14, 2022
42cb0b3
e
ruthrootz Apr 14, 2022
e3b4aed
e
ruthrootz Apr 14, 2022
c4921fd
e
ruthrootz Apr 14, 2022
08785d4
e
ruthrootz Apr 14, 2022
1295eb2
e
ruthrootz Apr 14, 2022
1646d79
e
ruthrootz Apr 15, 2022
3e8cb4c
e
ruthrootz Apr 15, 2022
80177d0
e
ruthrootz Apr 15, 2022
5821a43
e
ruthrootz Apr 15, 2022
295347b
e
ruthrootz Apr 15, 2022
c8ef7a7
e
ruthrootz Apr 15, 2022
1027608
e
ruthrootz Apr 15, 2022
7a88abd
e
ruthrootz Apr 15, 2022
00fbe31
e
ruthrootz Apr 15, 2022
779d1ab
e
ruthrootz Apr 15, 2022
036a217
e
ruthrootz Apr 15, 2022
6ef3a91
e
ruthrootz Apr 15, 2022
6dcf56c
e
ruthrootz Apr 15, 2022
a8d7d3e
e
ruthrootz Apr 15, 2022
bd2f6b5
e
ruthrootz Apr 15, 2022
3254a04
Update final-exam.md
ruthrootz Oct 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,24 @@

[WEEK ONE](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-one.md)


[WEEK TWO](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-two.md)

[WEEK THREE](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-three.md)

[WEEK FOUR](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-four.md)

[WEEK FIVE](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-five.md)

[WEEK SIX](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-six.md)

[WEEK SEVEN](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-seven.md)

[WEEK EIGHT](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-eight.md)

[WEEK NINE](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-nine.md)

[WEEK TEN](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-ten.md)

[WEEK ELEVEN](https://github.com/ruthrootz/java-oop-class-notes/blob/main/week-eleven.md)

[FINAL EXAM](https://github.com/ruthrootz/java-oop-class-notes/blob/main/final-exam.md)
Binary file added callback-methods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added complexity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions final-exam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# final exam topics

## essay questions
- Value of implementing data structures and code reuse. These questions are sort of ‘in your opinion’ questions and what I would be looking for is to use your knowledge of those topics and provide to me a response of a particular question. No coding required for those two questions.
- data structures: These are tried-and-true structures that are implemented in the most efficient way that has been discovered so far! Almost all big modern languages already have implementations of these structures. Most programmers know how to use them, so using them increases code clarity when someone reads the code using these structures. Some problems are uniquely suited to these structures as well. Scheduling tasks, for example, works just like a queue does, making it a perfect problem to use queues for. Using these out-of-the-box implementations also aids with code-reuse...
- Know...
- the ‘Shunting-yard algorithm’
- infix: 3 + 7 * 2 - 8 / (6 - 2)
- postfix: 3 7 2 * + 8 6 2 - / -
- steps
- add each number to the stack, one by one
- when you reach an operator, pop off the two top numbers, perform the operation, and add the result back to the stack
- there should be only one number on the stack at the end, and that's the answer to the problem
- the idea of semaphores
- the shortest path algorithm
- the structured programming movement
- make code as modular as possible so that it's clear and easy to modify
- elements: control structures, subroutines, blocks

## short answer questions
1) `Queue` principles
2) Adapter design principles
3) Decorator design pattern principle
4) `ArrayList` principles
5) `LinkedList` principles
6) Know your interfaces and what they do: `Iterator`, `Iterable`, `ListIterator`, `Collection`, `List`.
7) Know time complexity for `Array`, `List`, `Stack`, `Queue`.
![time complexity](complexity.png)

## multiple-choice
1) ArrayList and LikedList efficiencies - efficiencies for removing, adding, etc.
2) Choose best collection to apply to a given situation: storing payroll calculations, program to track progress in a maze, keeping track of customers in alphabetical order, driving dispatching system like Uber.

Basically make sure you know the ins and outs of the following data structures: `ArrayList`, `LinkedList`, `Queue`, or `Stack`.

## coding problems

### Decorator Pattern problem
1) Description: Need to create a system to allow for basic seat reservations and decorations for adding wifi.
2) You're given a UML diagram where you'll need to implement a few classes.
3) What you need to do is to look at the UML diagram and simply implement the methods using the decorator method.
4) You will be given a sample of what your output should look like.
5) You will be given a `RunMe.java` file with starter code.
Go over what the Decorator classes do:
1) Remember to declare your main object, `FlightSeat`.
2) Then just code up your getters and remember to instantiate the constructor for the classes extending the decorator classes.
3) Call the super class (`FlightSeatDecorator`) and do your modifications locally.

### Stacks problem
1) Description: The given problem is about balancing parentheses, obviously you have to make sure each parentheses has its open and respective closed parentheses.
2) Example: [{}], {}, ([{}]) are balanced, [{}, {, ({) are NOT.
3) Using a stack you need to check if a particular string is balanced or not. Return a `true` or `false`.
4) Tips: perhaps a string of opening strings, like {({.
5) Have a string of closing strings like })].
6) What you need to do is to iterate through the tokens.
7) If the tokens are starting strings then push to the stack.
8) If not then see that means it is an ending string so see if that particular string matches the top of the stack.
9) Work your way through the rest of the tokens.
10) Return false if any of the above steps don't work.
11) If the stack is empty then you know it's true, so return that.
12) Conclusion: know how stacks work and know your stacks methods: `empty()`, `push()`, `pop()`.

### Queues problem
1) Description: Need to implement a publish/subscribe model (like YouTube, etc.) by implementing two classes.
2) Will be given a UML diagram for the methods and variable for each class you need to implement. There are links to APIs you may need embedded in the specification.
3) You will be given a Queue object of a particular class will need to do such things as reading and removing oldest notifications (`poll()`), getting number of notifications (`size()`),
check if two subscribers are equal.
4) Conclusion: pretty simple problem, know how to use poll and size methods of queue.

### Lists problem
1) Description: Implement two methods using the `List` class. Links to the applicable Java API docs will be available.
2) You will do the following:
- Reverse a list in place in O(n) time, should not need to create any new lists.
- Merge two sorted lists in O(n+m) time. Same as what was done in the polynomial homework. Result should be ordered ascending.
3) Need to know the following interfaces: `List` and `ListIterator` methods and understand what they do.
3) So how do you reverse a list? Possibly have two list iterators from `List` class and iterate between both lists with one iterator starting from the end?
4) How do you merge a list? May need to do some comparisons. Again call list iterator from each list.
5) How do you declare a `ListIterator` obj? `ListIterator<E> blah = somelist.listIterator();`
6) Then manipulate blah to do the merge operation. You're comparing each letter in each list to see if one comes before the other in alphabet and take that one and add to result.
Empty file added week-eight.md
Empty file.
17 changes: 17 additions & 0 deletions week-eleven.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## queues
- queues are FIFO structures (first in, first out)
- they're an array of elements where you can only add to the end and remove from the beginning
- examples of real-world queues include people waiting in a checkout line
- queues are most often used in scheduling algorithms
- particularly in scheduling algorithms that deal with Poisson-distributed events
- methods that queues (should) implement
- `bool queue(E data)` adds `data` to the end of the array
- `E enqueue()` removes and returns the first element in the array
- `E peek()` returns the first element in the array without removing it
- `bool isEmpty()` tells whether the array has any elements in it (obviously)
- `LinkedLists` are the best structure to use to implement queues
- it's fast to add to the end of them
- and fast to remove from the beginning
- because of the head and tail nodes
- `ArrayLists` are only fast to remove/add to the end (O(1))
- any operation at the beginning of an `ArrayList` will be an O(n) operation
53 changes: 53 additions & 0 deletions week-five.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## Compare and contrast iterative versus sequential software lifecycle approaches.
- steps in SDLC: requirements analysis, design, development, testing, production, maintenance
- waterfall model
- phases
- requirements analysis: what should the product do?
- design
- what are the business rules?
- user stories are written at this point
- development
- what technologies will it use?
- what software design patterns?
- actual coding!
- testing
- unit testing
- integration testing (how all the modules work together)
- user testing (how long does it take user to complete tasks?)
- regression testing
- white box testing: testing the code while knowing about the code and how it works (unit testing)
- black box testing: testing the code as a user would use it, not knowing about how the code is working
- production
- maintenance
- change requests
- bug reports
- software spends most of its time here
- disadvantages
- costly to fix bugs
- slow
- not flexible
- produces software that isn't actually what the user wants
- spiral (scrum, agile) model
- uses short sprints
- each sprint goes through all the steps of SDLC
- adaptable to change
- build products incrementally
- gets user feedback regularly
- disadvantages
- complex process
- difficult to estimate
- not easy for project managers

## Use UML class diagrams to illustrate relationships between classes.
- identify classes by finding the nouns in the requirements analysis
- identify methods by finding the verbs
- identify interfaces by looking for adjectives (?)

## Use CRC cards to capture the responsibilities of each class and the relationships between classes.


## Use primitive operation counts and deductive reasoning to determine the efficiency of algorithms.


## Given a set of initial conditions, predict how the runtime of an algorithm is affected by increased input size

67 changes: 67 additions & 0 deletions week-four.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
## Explain the purpose and use of exception handling for error detection and correction.
- exception handling is used when the point at which an exception occurs is different from the point at which that error can or could have been corrected
- uncaught exceptions terminate the program
- the place where an exception is thrown is always different than the place it gets caught
- because you can't or don't want to fix the error in the same place where it happened

## Differentiate between checked and unchecked exceptions.
- unchecked exceptions are exceptions that happen during runtime
- unchecked exceptions are subclasses of `RuntimeException`
- they happen due to programmer error
- the programmer can write code to avoid these exceptions
- checked exceptions are exceptions that are explicitly thrown in the code
- checked exceptions are subclasses of `Exception`
- they account for things that happen that are outside of the programmer's control
- all checked exceptions must be caught or declared to be thrown
- `throws` is used to show that a method throws checked exceptions
- `public void someMethod() throws FileNotFoundException, SomeOtherCheckedException`
- wherever the function is called, it has to either be in a method that is marked with `throws` or it has to catch the exception/s

## Use the keywords throws, try, throw, catch, and finally to implement exception handling.
- `throw` indicates you've found an error, something that you can't fix
- `try` blocks wrap code that _might_ throw an exception
- you can then `catch` exceptions in the catch block
- a caught exception doesn't terminate the program
- you can chain `catch` blocks to catch specific exception types
- when chaining, you have to put the catch blocks in order of most to least specific exception types
- e.g., put `IOException` after `FileNotFoundException` because `FileNotFoundException` is a subclass of `IOException`
- if you caught them in the other order, `IOException` first, all `IOExceptions` _and_ `FileNotFoundExceptions` would be caught by the first block (`IOException`), since `FileNotFoundException` _is an_ `IOException`
- the `finally` block always runs, whether an exception was thrown or not
```
try
{
var result = methodThatMightThrowException();
}
catch (SomeExceptionType e)
{
// handle error here
}
catch (RuntimeException e)
{
// handle error here
}
finally
{
// this code will run no matter what
}
```

## Define and use a domain-specific exception hierarchy.
- **???**

## Read and write binary files.
```

```

## Read and write text files.
- line endings in Unix- vs. Windows-based machines
- Windows machines end lines with `\r\n`
- Unix-based machines end lines with just `\n`
```

```

## Read and write serialized object files.
## Define and explain the Serializable interface
## Distinguish between random and sequential access files.
23 changes: 23 additions & 0 deletions week-nine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## decorator pattern
- a decorator class implements some interface
- it _is an_ [insert interface name here]
- BUT it also _has an_ instance of that interface
- "decoratee" is the instance of the interface that the decorator class has
- if you extend the decorator class...
- instances of this concrete class can make the instance in the decorator class _immutable_
- IF you `@Override` all the methods that modify the decoratee
- this way you can safely make an instance of the concrete decorator that has an immutable [insert interface name here]
- any subclasses the interface requires must also be decorated, both in the decorator class and any concrete classes that extend the decorator

## decorator example (from Dr. Whittaker)
- `CollectionDecorator`
- the decorator class itself
- implements `Collection`
- has an instance of `Collection` called `decoratee`
- also has a subclass `IteratorDecorator` that implements `Iterator` and has an instance of `Iterator`
- `UnmodifiableCollection`
- extends `CollectionDecorator`
- overrides all of its methods
- leaves methods that modify the collection unimplemented (i.e. they throw `Unimplemented` exceptions)
- also has a subclass `UnmodifiableIterator` that extends `IteratorDecorator`
- the iterator methods that modify the collection (`remove`, `add`, etc.) throw `Unimplemented` exceptions
19 changes: 12 additions & 7 deletions week-one.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### inheritance
## inheritance
- what it is
- a hierarchy of classes, each one defining a more specific subset of the parent class (or "superclass")
- the subclass "is a" version of the superclass
Expand Down Expand Up @@ -38,7 +38,7 @@ vehicle
- parent methods and properties need to be `public` for them to be accessible in subclasses (or by actual instances of the subclass)
- every class implicitly extends Java's base Object class; Object is the parent class of all classes

### override and overload
## override and overload
- override (decorator: `@Override`)
- you're "overriding" when you make a method with the same name and signature of a method in the superclass
- when called by an instance of the subtype, the subtype/overridden version of the method will be run
Expand All @@ -49,19 +49,24 @@ vehicle
- within the same class, you can have multiple versions of the same method
- the return types and names must be the same, but the types, number and order of the parameters can be different

### polymorphism
## polymorphism
- what it means
- you can call the same methods and/or use the same logic with objects of different types
- a different method is called depending on the type of the object
- dynamic method lookup
- an object gets its type checked and then the correct override of a method is chosen and invoked
- this happens dynamically, during runtime

### late binding
- what it is
- **???**
## late binding
- this is when ther JVM determines the type of an object during runtime
- say you have an interface `Comparable` and classes `Blanket` and `Lightbulb` that implement it
- `Comparable` defines a method `compareTo()` that is obviously written differently in each subclass
- lastly, you have a class that uses `Comparable` objects and calls `compareTo()` in one of its methods
- this method takes in type `Comparable`
- the exact type of the object (and its specific version of `compareTo()` to call) is determined during runtime by the JVM
- early binding is when the type of an object is determined during compile time

### Liskov substitution principle and SOLID
## Liskov substitution principle and SOLID
- what SOLID stands for
- single responsibility principle: each class should represent one thing, each method should do only one thing, etc.
- open-closed principle
Expand Down
30 changes: 30 additions & 0 deletions week-seven.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## List the common operations and properties of all lists as distinct from collections.
- lists
- ordered
- operations happen at a particular index
- grow/shrink to accommodate add/remove actions
- `List<T>` extends `Collection<T>` and `Iterable<T>`
- collections
- unordered
- have size limits
- can be equal to each other even if the order of the elements is different
- `Collection<T>` extends `Iterable<T>`
- `ListIterator<T>`
- extends `Iterator<T>`
- adds `hasPrevious()`, `next/previousIndex()`, etc.
- can be initialized at specific indexes

## autoboxing (boxing/unboxing)
- this is when Java automatically converts primitive types into their `Object`/wrapper types
- example where this would be needed: when adding an `int` to an `ArrayList<Integer>`
- primitive -> object is "boxing"
- object -> primitive is "unboxing"

## Extend the AbstractCollection implementation into AbstractList and ArrayList implementations and justify design decisions.


## Analyze the ArrayList implementation to determine algorithmic efficiency.


## Use an ArrayList data structure to solve a problem.

Loading