UOW Week 10 Flashcards

1
Q

What does %s, %d, %f do?

A

s formarts Strings, d formats decimal integers, f formats floating-point numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

System.out.printf(“%s%10s%n”, “Ticker Symbol”, “Position”);

A

Ticker Symbol Position

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Example of array initialiser

A

String[] Stocks = {“BABA”, “JD”, “QCOM”};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Minimize this function: L(S) = N/S + S - 1

A

0 = 1 - N/S^2 which then equals to S = square root of N

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the quadratic formula?

A

x = -b(+-) root b^2 -4ac / 2a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

print a random number from a rand of 100 to 200

A

(int)Math.floor(Math.random() * ((200 - 100 + 1) + 100);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What do these mean: ∈, ∉, ⊂, ⊆, ⊄, |, ℤ

A

∈ - Element of
∉ - Not element of
⊂ - Proper subset of (A is a part of B but they aren’t equal, as in B is bigger)
⊆ - Subset of/Every element of (Since all of the members of set A are members of set D, A is a subset of D. Symbolically this is represented as A ⊆ D. Note that A ⊆ D implies that n(A) ≤ n(D) (i.e. 3 ≤ 6).)
⊄ - Not a subset of/Not every element of
|- Such that
ℤ - Integers (A number which is not a fraction; a whole number. Whole-valued positive or negative number or 0. The integers are generated from the set of counting numbers 1, 2, 3, . . . and the operation of subtraction. When a counting number is subtracted from itself, the result is zero. When a larger number is subtracted from a smaller number, the result is a negative whole number)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the benefits of seperating concepts into different classes in code?

A

To make recycling and reusing code easier and more efficient. In addition, testing the program is much easier when it has been divided into several concepts, each of which has its own separate logic and can function alone as a unit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between == and .equals()

A

== is a reference comparison, ie both objects point to the same memory location. .equals() evaluates to the comparison of values in the objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Random(), ie Random draw = new Random();

A

Creates a new random number generator. ie int wtf = draw.nextInt(100); (generate number between 0 and 100)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a stack trace?

A

prints what type of error occured followed by the line it occured at.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Name 5 things for troubleshooting

A
  1. Indenting code properly with the necessary parentheses.
  2. Verify variables are correctly named.
  3. Verify variables are initialised, or a NullPointerException error will occur.
  4. Testing the program flow with different inputs.
  5. Add print commands at stages of the program is see the values of certain variables at different stages of the programs execution to determine where the bug or error is located.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is test-driven development?

A

Test-driven development is constructing a software in small interations. Benefits include: focusing on requirements before writing code, code is easier to maintain and less debugging.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is refactoring in coding?

A

Cleaning the code while maintaining the functionailty of the program. Cleaning refers to improving readibility, dividing program into small classes and methods, and removing repetitive code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Name one catastrophe caused by a software error

A

NASA’s Mars Climate Orbiter, crashed because a sub contractor on the engineering team failed to make a simple conversion imperial units to metric, leading to a navigation error which caused the $125 million dollar craft crashing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly