CS 2110

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/35

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 11:59 PM on 9/28/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

36 Terms

1
New cards

What is a unit test

A small assertion you include in the code to test the specs

2
New cards

When writing unit tests, what should/shouldn’t we test?

Pre-conditions, ALWAYS assured.

3
New cards

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.

4
New cards

Glass-box testing

Looking @ code and using it to design tests better!

5
New cards

What is an object?

An object is an object made by a class, with its traits and everything.

6
New cards

What is a field?

Info that an object stores, the methods of a class, the traits.

7
New cards

Invariant

Before the object is finally created, it has to be something that is valid.

8
New cards

What do you know about public methods and invariants?

Public methods MUST have valid invariants.

9
New cards

What do you know about public methods and invariants?

Private methods MIGHT have invalid invariants.

10
New cards

The superclass “Animal” says what?

I can hold an animal.

11
New cards

If you’re making a new Animal, what is the decleration you would make to make a cat.

Animal hi = new Cat ();

12
New cards

Difference between Animal hi = new Cat(); and Cat hi = new Cat(); ?

methods that need an animal, wont be able to use cats exclusive features.

<p>methods that need an animal, wont be able to use cats exclusive features.</p>
13
New cards

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.

<p>A condition that must always stay true for a valid object. Example: balance ≥ 0; code must prevent withdrawals that break it.</p>
14
New cards

Would feed (Animal x) work on a Cat() ?

Yes with polymorphism.

15
New cards

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.

16
New cards

What are abstract classes usually used for?

Abstract classes are used for very broad things. “Items” “Cars” “Animals” abstract class “Animal”

17
New cards

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.

18
New cards

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.

<p>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.</p>
19
New cards

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!

20
New cards

When writing specs, what should you always do? 3 Steps!

  1. Look at each parameter and ask, how can this cause error within the method?

  2. Is there an array and indexing, during indexing, x has to be between 0 and a.length()

  3. plug negative, null, and 1 million


21
New cards

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>
22
New cards

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!

23
New cards

What is recursion actually doing?

Shrinking what needs to be searched!

24
New cards

For a method to “throws an Error” what does that mean?

it might throw an error, and if it does be prepared.

25
New cards

For a method to “throw an Error” what does that mean?

It 100% throws an Error, CATCH IT!

26
New cards

What is an interval?

3 to 6, would include all number in between

27
New cards

What is defensive programming?

Something you do when you think people didn’t follow specs.

28
New cards

When throws comes at you, what do when calling that method?

try{}
catch (error)
return value;

29
New cards

Tell me about the two assert statements you know!

asset x>0
assertEquals (true, x+1 > 0)

(answer, thing tested)

30
New cards

Base case meaning

Where recursion stops

31
New cards

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.

32
New cards

Merge Sort

divide and conquer

33
New cards

Quicksort.

Take out one number, put it in its correct index, then sort left side and right side.

34
New cards

What is the pivot?

The number you remove in quicksort();

35
New cards

tell me about these signs and what they mean (theyre connected) “:” “?”

condition? true : false

36
New cards

Mathematical operations in java how solve!

They follow PEMDAS