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
2
Q
What is the index of the first element in an array?
A
0
3
Q
How do you access the 4th element of an array with the name “arr”?
A
arr[3]
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.
5
Q
What is the cause of a StackOverflow error?
A
Infinite loop or infinite recursion, due to badly defined stopping condition.