Java Syntax
Write Some Code
Formal Definitions of Sorts
Arrays of Various Dimensions
Things to Import
100
The punctuation mark placed after commands given to the compiler. For instance, it would follow "int i = 7".
What is a semicolon?
100
An if statement that will remain true so long as x is less than 5.
What is if (x < 5) { //irrelevant }
100
According to Wikipedia, this sort "iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, [the] sort removes one element from the input data, finds the location it belongs within the sorted list, and inserts it there. It repeats until no input elements remain." Options: selection sort, insertion sort, merge sort, and bubble sort.
What is insertion sort?
100
A one-dimensional array called "arr" containing only the int '7'
What is int [] arr = {7};
100
The importation of the Scanner class.
What is import java.util.Scanner; ?
200
These are used by if-statements, while-statements, and for-statements.
What are parenthesis?
200
A while loop that will remain true so long as i, which is initially 0, is less than 34, and where i is increased by one within the body.
What is int i = 0; while (i < 34) { i++; //i+=1; and i = i+1; are also acceptable in place of i++; }
200
According to Wikipedia, the steps to this sort are: 1. "Divide the unsorted list into n sublists, each containing 1 element (a list of 1 element is considered sorted)." 2. "Repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This will be the sorted list." Options: selection sort, insertion sort, merge sort, and bubble sort.
What is merge sort?
200
A two dimensional array called "arr" containing two arrays, each containing only the number '7'
What is int [] [] arr = { {7}, {7} };
200
The importation of all java.util classes.
What is import java.util.*; ?
300
Rather than using nested if and else statements, it is sometimes helpful to use...
What are if-else statements?
300
A for loop that will remain true so long as i, which is initially 7, is less than 56. i is increased by 1 each iteration of the for loop, which contains no body.
What is for (int i = 7; i < 56; i++); //i+=1 and i = i+1 are also acceptable in place of i++
300
According to Wikipedia, this sort "divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right." Options: selection sort, insertion sort, merge sort, and bubble sort.
What is selection sort?
300
A three dimensional array called "arr" containing three arrays, each containing two arrays which contain only the number '7'
What is int [] [] [] = { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } };
300
The importation of all java.applet classes.
What is java.applet.*; ?
400
This is not a regular for loop, it is a... int i = 0; for(i; i < test; i++);
What is a for loop without instantiation?
400
A recursive call named 'mystery' which takes int i and checks to see if i <= 0. If i <= 0, zero is returned, and if not, mystery(i-1) is called.
What is public int mystery(int i){ if (i <= 0) { return 0; } else { return mystery(i-1); } }
400
According to Wikipedia, this sort "is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. Passes through the list are repeated until no swaps are needed, which indicates that the list is sorted."
What is bubble sort?
400
A four-dimensional array named "arr" containing four arrays which each contain three arrays which contain two arrays which contain only the number '7'
What is int [] [] [] [] arr = { { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } } };
400
The importation of the math class.
What is java.lang.Math; ?
500
Places in a for loop where a semicolon can be placed without causing a compile-time error.
What are after the instantiation, after the test statement, and in place of the body. For instance: for (int i = 0; i < 5; i++); A semicolon is required after the instantiation and test statement, but not in place of the body.
500
A runtime error.
What is division by zero, as an example, although these vary. Anything that could only be detected when the program executes. Another example would be a user inputting a String when the line 'answer = scan.nextInt();' is ran.
500
A sort which divides the list into smaller lists to be sorted, and is generally considered one of the fastest sorts.
What is merge sort?
500
A five-dimensional array named "arr" containing five arrays, each containing four arrays which each contain three arrays which contain two arrays which contain only the number '7'
What is int [] [] [] [] [] = { { { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } } }, { { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } } }, { { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } } }, { { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } } }; { { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } }, { { {7}, {7} }, { {7}, {7} }, { {7}, {7} } } } }; also acceptable: What is the reason people tend to stick with 1D and 2D arrays
500
The importation of the Thread class.
What is import java.lang.Thread; ?
M
e
n
u