True or False? This will result in an Error:
int[] arr = new int[n];
for(int i=0; i<=n; i+=1) {
arr[i]++;
}
What is True?
(Array Index Out of Bounds Error)
This Number Will Make the Loop Print all Odd Numbers between 0 and 100:
for(int i=i; i<100; i+=?) {
System.out.println(i);
}
What is 2?
These Will Be the Number(s) Printed from the Following Code:
int[] nums = new int[] {1, 2, 3};
for(int i=0; i<nums.length; i++) {
System.out.println(nums[i]);
}
What is 1 2 3?
int[] nums = new int[5];
This is the Number of Elements Accessed By the Following Loop:
for(int i=0; i<nums.length; i+=2)
What is 3?
In the Code, These are the Character(s) that Follow a Variable to Make it an Array.
Square Brackets/Hard Brackets/[]
True or False? This will result in an Error:
int[] nums = new int[n];
for(int i=nums.length; i<0; i++) {
nums[i]++;
}
What is False?
(Loop Never Runs)
This Number Will Allow the Loop to Access All of the Elements in the Array Without Going Out of Bounds:
(There are two answers)
boolean[] truths = new boolean[] {true, false, true, true, false};
for(int i=0; i<(?); i++) {
truths[i]=true;
}
What is 5 or truths.length?
This is the What Be Will Printed From the Following Code:
System.out.println((int)(Math.random());
What is 0?
This is the "unenhanced" version of the following loop:
for(int n : nums)
What is for(int i=0; i<nums.length; i++)?
("i" can be any valid variable name)
This is the Keyword that is Used to Make a Variable Unchangeable
What is Final?
True or False? This will result in an Error:
String[] words = new String[] {"RAMS", "Comp", "Sci, null, More RAMS"};
for(int i=0; i<words.length; i++) {
System.out.println(words[i].charAt(0));
}
What is False?
(The null is not actually null, it is inside the String "Sci, null, More RAMS", so no Null Pointer Exception will occur)
This Condition Will Cause the Code to Only Print Even Numbers:
public void printEvensOnly(int n) {
if( ? ) {
n++;
}
System.out.println(n);
}
What is n%2==1?
(or if you wanna be crazy: n/2*2!=n)
This is What is Printed from the Following Code:
boolean[] arr = new boolean[5];
for(int i=0; i<arr.length; i++) {
if(i%2==0) {
System.out.println(arr[i]);
}
else {
System.out.println(!arr[i]);
}
}
What is false, true, false, true, false?
This is the Bounds For a For Loop that Will Only Access the Odd Elements of the List, "nums".
What is for(int i=1; i<nums.size(); i+=2)?
This Static Class is Full of Useful Methods for Performing Basic Numeric Operations.
What is the Math Class?
True or False? This will result in an Error:
String mantra = "RAMS";
if(mantra.contains('A')) {
System.out.println("I am Academic!");
}
What is True?
(Incompatible Types - Unlike .indexOf(), .contains() requires a String parameter)
This is the Code that will Choose a Random Letter from a 5 Letter Word:
public char anyCharacter(String str) {
return str.charAt(???);
}
What is (int)(Math.random()*5)?
This is What Will Be Printed From the Following Code:
String[] words = new String[] {"Computer ", "Science", "A "};
for(int i=0; i<words.length; i++) {
System.out.println(words[(i+2)%3]);
}
What is "A Computer Science"?
This is the Loop Bounds That Would Access as Many Elements as Possible Without Getting an Error While Containing the Following Code:
nums[i]=nums[i-2]+nums[i+1];
What is for(int i=2; i<nums.length-1; i++)?
This is the Method Signature for a Method That:
1. Takes a Single Integer Parameter (Any Name Works)
2. Can't be Accessed By Other Classes
3. Is Named "whatItDo"
4. Is Compatible with the Following Statement:
return Integer.toString(100);
What is private String whatItDo(int n)?
This is the name for the error that will occur from the following:
public String whatItDo(String str) {
str=str.replaceAll("e","");
}
What is a Missing Return Statement error?
This is the Code that Will Correctly Count the Number of Digits if a positive number "n" was Turned into a Binary Number:
public int binaryDigits(int n) {
if(n<=1) {
return 1;
}
return (?);
}
What is 1+binaryDigits(n/2)?
This is What Will Be Printed From the Following Code:
for(int i=0; i<3; i++) {
char c = (char)(i+'x');
System.out.println(c);
}
//This will not Result in an Error
What is "xyz"?
This is the Bounds For a For Loop That Will Only Access the Elements With an Index that is a Power of Two (including 1) for the Array, "arr".
What is for(int i=1; i<arr.length; i*=2)
(i+=i Also Works)
This Single Character Is Used to Access the Attributes/Methods of an Object or Static Class
What is a period?