Refresh this page in case I made changes since you last viewed it. Changes will not be made during the exam.
This document is to be used for the prog10082 mid term exams.
[ Jump to Mid Term #1 Reference ]
if (expression) { ... }
if (expression) { .... } else { .... }
if (expression) { .... } else if (expression) { .... } else if (expression) { .... } else { .... }
switch (expression) { case x: case y: case z: default: }
Also: break;
statement
[ MT #1 Ref | MT #2 Ref | Top of Page ]
Steps to using RegEx classes:
Regex Syntax
[ MT #1 Ref | MT #2 Ref | Top of Page ]
while (condition) { }
do { } while (condition);
for (initializer; condition; increment) { }
Priming-Read/Continuing-Read Pattern
priming read while (condition) ... continuing read
[ MT #1 Ref | MT #2 Ref | Top of Page ]
[ MT #2 Ref | Top of Page ]
class header: public class ...
main() header: public static void main(String[] args)
Semi-colons: at the end of executing statements, such as:
No semi-colon after:
IPO: Input / Processing / Output
Import statement:
import package.name.Class;
Escape sequences:
Categories of Errors:
Generate a Random Number:
between 1 and n:
(int)(Math.random() * n + 1)
between x and y:
(int)(Math.random() * (y - x + 1) + x)
[ MT #1 Ref | MT #2 Ref | Top of Page ]
Reference types
Primitive Types:
Notations for floating point values:
Floating Point Number Storage (IEEE 754)
Data Type | Description | # bits for Coefficient |
# bits for Exponent |
# bits for Sign |
---|---|---|---|---|
float | Single-precision floating-point | 23 | 8 | 1 |
double | Double-Precision floating-point | 52 | 11 | 1 |
[ MT #1 Ref | MT #2 Ref | Top of Page ]
Variable declaration:
type varname;
Variable declaration with initialization:
type varname = value;
Constants:
Assignment operator: =
Concatenation operator: +
String methods:
Arithmetic operators: + - / * %
Unary Arithmetic operators: ++ --
(both pre-fix and post-fix)
Augmented Assignment operators: += -= /= *= %=
Math Class methods
Casting operator: (type)
[ MT #1 Ref | MT #2 Ref | Top of Page ]
Scanner: java.util
Scanner whatever = new Scanner(System.in);
Scanner methods:
System.out methods:
Conversion Codes and other Symbols:
Standard format for format specifier:
%[width].[digits][code]
[ MT #1 Ref | MT #2 Ref | Top of Page ]
Relational/Conditional Operators:
Logical Operators:
Conditional Operator: ?:
(booleanExpression) ? valueIfTrue : valueIfFalse
[ MT #1 Ref | MT #2 Ref | Top of Page ]