This term is used for inheritance from super class.
What is extends?
Given int[] arr = {3, 5, 4, 7, 8, 9}, what value is in arr[arr.length/2]?
What is 7?
This kind of string, immutable and defined in code, is delimited by double-quotes (e.g. "Hello")
What is a string literal?
int x = 1;
while (x != 100)
x*=2;
System.out.println(x);
This is the the result of the executing the code above.
This is the primary reason one would use an ArrayList over an Array.
What is dynamic resizing? (Or the ability to add elements/remove elements/change size/etc.)
"abcdefgh".substring(2, 4)
What is "cd"?
When a subclass has a method with the same name and inputs as the superclass, we can say that this method has _________ the superclass method.
Overridden
for(int j = 0; j <= 100; j += 2)
for(int k = 100; k > 0; k--)
x++;
The set of classes that are thrown as error messages.
What are Exceptions?
To get the number of elements in an array, you use ____; to get the number of elements in an ArrayList you use ____. (Make sure to include parentheses where necessary)
What are "length" and "size()"?
if (num > 0)
if (num < 10)
System.out.println("AAA");
else
System.out.println("BBB");
This is printed after executing the code above if num = 20.
What is BBB?
The binary number corresponding to 19 (decimal)
What is 10011?
The reason that the declaration
ArrayList<int> list;
will not compile.
What is the use of int instead of Integer?
public boolean mystery(int x){
if (x == 0)
return true;
else if (x < 0)
return false;
else
return mystery(x - 2);
}
Consider the following method that is intended to return true with probability prob and false with probability 1. - prob.
//precondition: 0.0<=prob<=1.0
public boolean chance(double prob)
{ //statement}
Replace //statement with a single line so that the method works. Hint: use Math.random().
What is return Math.random() < prob?
Given
ArrayList<String> list = new ArrayList<>();
list.add("A");
list.add("B);
list.add("C");
list.add(0,"D");
This is what
System.out.println(list.remove(list.size()%3));
will print.
What is A?
Given the method, what is returned if we call it with value = 4.
public int method(int value){
if (value < 1)
return 0;
else
return 1 + method(value-1) + method(value-2);
}What is 7?