Lecture 5 Flashcards

1
Q

What is the java syntax for declaring and allocating memory to an array?

A

e.g. int[] row = new int[5]

for an array of 5 integers

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

What is the index of the first element in an array?

A

0

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

How do you access the 4th element of an array with the name “arr”?

A

arr[3]

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

What is “recursion” in the context of java?

A

a method that (in certain cases) calls itself, i.e. the result of the method for parameter p = x, depends on the result of the method for parameter p = y, for some pair of x, y.

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

What is the cause of a StackOverflow error?

A

Infinite loop or infinite recursion, due to badly defined stopping condition.

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