CSE 121
CSE 121
  • Home / Calendar
  • Syllabus
  • Assignments
  • Resubmissions
  • Exam
  • Getting Help
  • Course Staff
  • Grading Rubrics
  • Resources

  • Course Tools
  • EdStem
  • Gradescope
  • Grade Calculator
  • Anonymous Feedback
  • Acknowledgements

CSE 121 Final Exam Reference Sheet


DO NOT WRITE WORK YOU WANTED GRADED ON THIS PAGE. IT WILL NOT BE GRADED.

List of Allowed Methods¶

String Method Description
charAt(i) Returns the character in this String at index i
contains(str) Returns true if this String contains str inside it, returns false otherwise
startsWith(str) Returns true if this String starts with str, returns false otherwise
endsWith(str) Returns true if this String ends with str, returns false otherwise
equals(str) Returns true if this String is the same as str, returns false otherwise
equalsIgnoreCase(str) Returns true if this String is the same as str ignoring capitalization, returns false otherwise
indexOf(str) Returns the first index in this String where str begins, returns -1 if not found
length() Returns the number of characters in this String
replace(str1, str2) Returns a new String with all occurrences of str1 in this String replaced with str2
substring(i) Returns characters in this String from index i (inclusive) to the length of the String (exclusive)
substring(i, j) Returns characters in this String from index i (inclusive) to j (exclusive)
toLowerCase() Returns an all-lowercase version of this String
toUpperCase() Returns an all-uppercase version of this String
Random Method Description
nextInt(max) Returns a random integer from 0 (inclusive) to max (exclusive)
Math Method Description
Math.abs(val) Returns the absolute value of val
Math.max(val1, val2) Returns the larger of the two values val1 and val2
Math.min(val1, val2) Returns the smaller of the two values val1 and val2
Math.pow(base, exp) Returns the value of base raised to the exp power
Math.sqrt(val) Returns the square root of val
Scanner Method Description
next() Returns the next token as a String
nextLine() Returns the entire line as a String
nextInt() Returns the next token as an int, throws exception if cannot
nextDouble() Returns the next token as a double, throws exception if cannot

Arrays Reference¶

// Array Usage Examples
type[] name = new type[length];
type[] name = {VAL1, VAL2, VAL3, ...};

type[][] name = new type[numRows][numColumns];
type[][] name = {
            {VAL1, VAL2, VAL3, ...},
            ...
            {VAL4, VAL5, VAL6, ...}
};
Using Arrays Description
int value = name[i] Get the value at index i
name[i] = value Set the value at index i
name.length Get the number of elements in name
Using 2D Arrays Description
int value = name[i][j] Get the value at row i, column j
name[i][j] = value Set the value at row i, column j
name.length Number of rows (number of inner arrays)
name[0].length Number of columns in first row (length of first inner array)

Search

Search the class website; related sections and pages will appear below. Note: this search is not as forgiving with typos as other search engines.