1/35
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is a unit test
A small assertion you include in the code to test the specs
When writing unit tests, what should/shouldn’t we test?
Pre-conditions, ALWAYS assured.
Black-box testing
Not looking at the code inside, just specs to make a test. If specs promise to x2 input, the test will just test what it says.
Glass-box testing
Looking @ code and using it to design tests better!
What is an object?
An object is an object made by a class, with its traits and everything.
What is a field?
Info that an object stores, the methods of a class, the traits.
Invariant
Before the object is finally created, it has to be something that is valid.
What do you know about public methods and invariants?
Public methods MUST have valid invariants.
What do you know about public methods and invariants?
Private methods MIGHT have invalid invariants.
The superclass “Animal” says what?
I can hold an animal.
If you’re making a new Animal, what is the decleration you would make to make a cat.
Animal hi = new Cat ();
Difference between Animal hi = new Cat(); and Cat hi = new Cat(); ?
methods that need an animal, wont be able to use cats exclusive features.

What does an invariant look like , give me an example!
A condition that must always stay true for a valid object. Example: balance ≥ 0; code must prevent withdrawals that break it.

Would feed (Animal x) work on a Cat() ?
Yes with polymorphism.
If you would decide to go against a method’s pre-conditions, why would that not be a good thing? What would that mean for class invariants?
Going against a method’s pre-conditions wouldn’t be a good thing because you’re expected to 100% follow them before anything, that’s why they’re not unit tested. And if you don’t follow them, well the method doesn’t have to protect class invariants.
What are abstract classes usually used for?
Abstract classes are used for very broad things. “Items” “Cars” “Animals” abstract class “Animal”
What happens if Animal is an abstract class and you do Animal a = new Animal();
it wouldn’t work, you can’t make a new Animal, its too abstract! Animal a = new Dog(); would work.
Animal a = new Dog(); why do this instead of Dog a = new Dog();
Animal a = new Dog(); lets you treat a Dog as an Animal, making code more flexible because a can refer to any subclass of Animal.

Give me an example of an abstract method and what happens when you extend it from an abstract class. What happens if you don’t declare an abstract method in an extended private class?
Abstract class may have abstract methods, “abstract void makeSound()” but nothing is declared in it, it’s just a trait. When you make Dog, the dog will have makeSound() in it, and has to declare it itself because its no longer abstract in an abstract class! So put this.makeSound = “woof”; If not declared, dog must become abstract!
When writing specs, what should you always do? 3 Steps!
Look at each parameter and ask, how can this cause error within the method?
Is there an array and indexing, during indexing, x has to be between 0 and a.length()
plug negative, null, and 1 million
The command final int x = 3; what doesn’t work on it and what would change it in a different scenario? Describe the image attached for arrays!. Describe how final int[] counts could be mutated to change an int in its array!
x+=2
or x=5
would never work.
however, if it is inside an array {3,5,2} in final int[] counts, looks like the image attached.
![<p>x+=2<br>or x=5<br>would never work.<br>however, if it is inside an array {3,5,2} in final int[] counts, looks like the image attached.</p>](https://assets.knowt.com/user-attachments/d9398a91-a53b-48c7-957e-20dd2c7d795d.png)
What does the saying “method invocation with bar = 1” mean?
Don’t end until bar is on its = 1 run and it goes until //HERE!
What is recursion actually doing?
Shrinking what needs to be searched!
For a method to “throws an Error” what does that mean?
it might throw an error, and if it does be prepared.
For a method to “throw an Error” what does that mean?
It 100% throws an Error, CATCH IT!
What is an interval?
3 to 6, would include all number in between
What is defensive programming?
Something you do when you think people didn’t follow specs.
When throws comes at you, what do when calling that method?
try{}
catch (error)
return value;
Tell me about the two assert statements you know!
asset x>0
assertEquals (true, x+1 > 0)
(answer, thing tested)
Base case meaning
Where recursion stops
How does insertionSort():
checks an index, sees if its neighbor is greater, swaps if it is, then follows the new swapped index if it WAS greater.
Merge Sort
divide and conquer
Quicksort.
Take out one number, put it in its correct index, then sort left side and right side.
What is the pivot?
The number you remove in quicksort();
tell me about these signs and what they mean (theyre connected) “:” “?”
condition? true : false
Mathematical operations in java how solve!
They follow PEMDAS