Code Analysis
This page is incomplete. It does not cover all the important aspects of this subject. You can help by adding relevant information where relevant. |
Code Analysis | ||||
Inquiry & Lab Event | ||||
Forum Threads | 2020 | |||
There are no tests available for this event | ||||
There are no images available for this event | ||||
There are no question marathons for this event | ||||
This event was not held recently in Division B | ||||
This event was not held recently in Division C |
Code Analysis is a Division B and Division C event that was first run as a trial event at the 2018 Virginia state tournament and at the 2019 Wisconsin state tournament. It was also run at the 2019 Massachusetts state tournament as Python Code Analysis, using Python as the target language rather than Java. At the 2020 Washington state tournament, it replaced Ping Pong Parachute. Competitors are asked to determine the output or error that a given piece of code outputs without running the code. Each team is allowed one 8.5"x11" double-sided reference sheet, or two single-sided reference sheets of the same size.
Contents
The Event
Teams are not allowed to bring electronic devices into the testing room. All code given will be in Java, but problems focus on general programming concepts as opposed to specific qualities of Java. Problems may be written in a variety of ways, such as a series of statements, a method to be called with specific arguments, or a complete program with a main() method. All inputs and values will be specified, and no external inputs are allowed. All code given will also be properly indented.
While problems may be written in different ways, there are only two types of answers that will be requested. The competitor will determine the output of the code as created by System.out.print(), System.out.printIn(), and/or System.out.format() if a problem has an output. Space will be provided for the competitor to write their answer, and if the answer depends on spacing then a grid will be given so the answer is aligned properly. However, if the code has an error, then the competitor will be asked to describe the run-time error that occurs when the code is run. The error message or exception type does not need to be reproduced, but the competitor must describe what goes wrong and how to correct it.
Subjectivity in Test Writing
Test writers are free to craft the test according to their own coding philosophies. Based on an informal survey of a half dozen 2018/2019 tests:
- some embrace obfuscation, while others stick to clean ("honest") code.
- nearly all tests have at least one problem with recursion, although this recursion often ends up being simple single-branch nesting of no more than 3 levels.
- some tests emphasize mastery of printf and precise output formatting -- \n, whitespace, ASCII, etc. Other tests simply calculate numbers and print them, one per line.
- non-descriptive variable names and method names are very common -- i, x, n, foo, etc.
- some tests use nonsensical junk code with zero practical value. Other tests are full of real, usable code -- sorting, towers of hanoi, prime number calculations, etc.
Binary
Binary is the most basic form of data used by a computer. While most programs are not written in binary, it is important to have an understanding of how binary works. There are only two digits used in binary code - 0 and 1. Each number is known as a bit, and there are eight bits in a byte. Half a byte (4 bits) is also known as a nibble. Individual bits can be manipulated by bitwise operations, such as AND (&), OR (|), or XOR (^). Binary numbers are also known as bit strings, and when translated into decimal or hexadecimal numbers encode for specific data.
ASCII
Operators
Java can manipulate variables in a variety of ways using operators. An operator represents an action or a process, and return the result of that action being performed on one or more operands. The operand is the value which a given action is being performed on. Some operators appear much more frequently than others, but all have their own uses.
Arithmetic Operators
In most cases, arithmetic operators are the same as they are in algebra. However, Java has a couple of additional operators not typically found in math.
Operator | Description | Example |
---|---|---|
+ (Addition) | Adds values on either side of the operator. | 2 + 5 returns 7. |
− (Subtraction) | Subtracts the value on the right of the operator from the value on the left. | 2 - 5 returns -3. |
* (Multiplication) | Multiplies values on either side of the operator. | 2 * 5 returns 10. |
/ (Division) | Divides the value on the left side of the operator by the value on the right. | 10 / 5 returns 2. |
% (Modulus) | Divides the value on the left side of the operator by the value on the right and returns the remainder. | 10 % 3 returns 1. |
++ (Increment) | Increases the value of the operand by 1. | 5++ returns 6. |
−− (Decrement) | Decreases the value of the operand by 1. | 5-- returns 4. |
Relational Operators
Relational operators show the relationships between two primitives. All relational operators return a boolean, meaning that they are either true or false. The operator must compare the same data type otherwise the program will throw a compiler error. Some of these are also found in algebra, just like the arithmetic operators.
Operator | Description | Example |
---|---|---|
== (Equal To) | Returns true if both primitives are of the same value. Otherwise, it returns false. | int x = 2; if (x == 5) { //if x is equal to 5... System.out.println("This statement will not print since 2 == 5 is false"); } else { //otherwise System.out.println("This statement will print instead"); } |
!= (Not Equal To) | Returns true if both primitives are of different values. Otherwise, it returns false. |
int x = 2; if (x != 5) { //if x is not equal to 5... System.out.println("This statement will print since 2 != 5 is true"); } else { //otherwise System.out.println("This statement will not print"); } |
> (Greater Than) | Returns true if the primitive on the left side is larger than the primitive on the right side. Otherwise, it returns false. |
int x = 2; boolean isXGreaterThanZero = x > 5; // You can use logical operators and assign the return value to a boolean! if (isXGreaterThanZero) { // if x is greater than 5... System.out.println("This statement will not print since 2 > 5 is false"); } else { // otherwise... System.out.println("This statement will print instead"); } |
< (Less Than) | Returns true if the primitive on the left side is smaller than the primitive on the right side. Otherwise, it returns false. |
int x = 2; boolean isXGreaterThanZero = x < 5; // You can use logical operators and assign the return value to a boolean! if (isXGreaterThanZero) { // if x is less than 5... System.out.println("This statement will print since 2 < 5 is true"); } else { // otherwise... System.out.println("This statement will not print"); } |
>= (Greater Than Or Equal To) | Returns true if the primitive on the left side is larger than or equal to the primitive on the right side. Otherwise, it returns false. |
int x = 2; if (x >= 2) { // if x is greater than or equal to 2... System.out.println("This statement will print since 2 >= 2 is true"); } else { // otherwise... System.out.println("This statement will not print"); } |
<= (Less Than Or Equal To) | Returns true if the primitive on the left side is smaller than or equal to the primitive on the right side. Otherwise, it returns false. |
int x = 2; if (x <= 5) { // if x is less than or equal to 5... System.out.println("This statement will print since 2 <= 5 is true"); } else { // otherwise... System.out.println("This statement will not print"); } |
Bitwise Operators
NOTE: All bitwise evaluations are done in binary. They all return the primitive number type (int, long, byte, char) back.
Operator | Description | Example |
---|---|---|
| (OR) | Compares each binary digit and if either digit is a 1, then it gives back a 1. Otherwise it gives back a 0. | 7_{10} | 18_{10} = 111_{2} | 10010_{2} = 10111_{2} = 23_{10} |
& (AND) | Compares each binary digit and if both digits is a 1, then it gives back a 1. Otherwise it gives back a 0. | 7_{10} & 18_{10} = 111_{2} & 10010_{2} = 10_{2} = 2_{10} |
^ (XOR) | Compares each binary digit and if only one of the digits is a 1, then it gives back a 1. Otherwise it gives back a 0. | 7_{10} ^ 18_{10} = 111_{2} ^ 10010_{2} = 10101_{2} = 21_{10} |
~ (NOT/Complement) | For each digit, it sets each 1 to 0 and each 0 to 1. | ~18_{10} = ~10010_{2} = 1101_{2} = 13_{10} |
>> (Right Shift) | Shifts all the bits to the right. Preserves the sign, meaning it keeps the same number of binary digits. | 10>>1=5 since 1010_{2} shifted to the right 1 is 0101_{2} which is 5_{10}. |
>>> (Unsigned Right Shift) | Shifts all the bits to the right. This is the unsigned version of the signed right shift. It doesn't keep the same number of binary digits. | 10>>1=5 since 1010_{2} shifted to the right 1 is 101_{2} which is 5_{10}. |
<< (Left Shift) | Shifts all the bits to the left. | 10<<1=20 since 1010_{2} shifted to the left 1 is 10100_{2} which is 20_{10}. |
Logical Operators
Compares two boolean variables and returns a boolean.
Operator | Short Circuit | Description | Example |
---|---|---|---|
| (OR) | || | Will return true if either boolean condition is true. Will return false if both conditions are false. | If bool1 is true and bool2 is false, then bool1 | bool2 is true. |
& (AND) | && | Will return true if both boolean conditions are true. Otherwise, it will return false. | If bool1 is true and bool2 is false, then bool1 & bool2 is false. |
^ (XOR) | Will return true if one, but not both, of the boolean conditions is true. Will return false if both conditions are true or false. | If bool1 is true and bool2 is true, then bool1 ^ bool2 is false. | |
! (NOT) | Flips the boolean value. | If bool1 is false, then !bool1 is true. |
De Morgan’s Law
Given that A and B are both boolean variables, De Morgan’s Law states that
- [math]!(A \& B) == !A \| !B[/math]
and
- [math]!(A \| B) == !A \& !B[/math]
Short-Circuit Operators
Short circuit operators will not evaluate the second part of a boolean operation if it isn’t necessary. It is written in code as || for OR operations and && for AND operations.
An example, if the condition being evaluated is A || B
and A is true, then regardless what B is, A || B
will be true, so the computer doesn’t evaluate B.
For the expression A && B
and A was false, then the expression would return false regardless of what B is.
The reason why a short-circuit for XOR doesn’t exist is because if you evaluate A ^ B
, if A is either true or false, the value B still needs to be evaluated to see whether the expression A ^ B
returns true or false.
Assignment Operators
Assignment operators allow data types to be assigned values.
Operator | Description | Example |
---|---|---|
= (Assignment) | It is used to set the value to a data type. Both primitives and Objects can use this operator. |
int x; // By default, Java sets uninitialized primitives to 0 x = 10; // x is now set to 10 System.out.println(x); // This will print 10 |
+= (Increment) | It is used to add some primitive value to itself. This is similar to doing x = x + y. This can only be used with PRIMITIVES excluding booleans. |
int x = 10; x += 20; System.out.println(x); // This will print 30 |
-= (Decrement) | It is used to subtract some primitive value to itself. This is similar to doing x = x - y. This can only be used with PRIMITIVES excluding booleans. |
int x = 10; x -= 20; System.out.println(x); // This will print -10 |
Miscellaneous Operators
Control Flow Statements
Conditional
If-Else
If
An if statement allows for a block of code to run if it meets a certain boolean condition. If the conditional it skips over the block of code and continues. The syntax for an if statement is as follows:
if (/*conditional*/) { // The block of code that runs if the conditional is true }
If the brackets are not included with the if statement, then the statement immediately after if is the consequence.
if (/*conditional*/) // This line will run if the conditional is true // This line is not part of the if statement
Here are some examples that can be run:
This is an example that shows when the conditional is true.
// This code should print "Hello World!" int x = 10; if (x == 10) { // this statement is true, so it will run the code within the brackets System.out.print("Hello "); } System.out.println("World!");
This is an example that shows when the conditional is false.
// This code should print "World!" int x = 10; if (x > 20) { // this statement is false, so it will skip the code within the brackets System.out.print("Hello "); } System.out.println("World!");
This is an example of using an if statement without the brackets.
// This code should print "World!" int x = 10; if (x > 20) // this statement is false, so it will skip the immediate statement below System.out.print("Hello "); // Since this line is considered as the "block" of code in the if statement, this will not run System.out.println("World!");
Else
Else If
Switch
Loops
While
Do-While
For
For each
Data Types
Primitive
Primitives are a data type that store their data in a certain amount of bytes. All these types can all be defined by assigning integers to them.
int
An int is one of the most fundamental types of primitives. Ints are allocated 4 bytes (32 bits) and can range from -2,147,483,648 to 2,147,483,647 in decimal. These numbers are easily accessible just by doing Integer.MIN_VALUE
and Integer.MAX_VALUE
respectfully.
The following code defines an int.
int x;
By default, Java sets the value of all primitives to 0. So, if x
were to be printed, it would print out "0".
To initalize it, use the assignment operator. This can also be done while the int is defined.
int x = 10; // x is 10 x = 20; // x is now 20
Ints are one of a couple of primitives that can use Arithmetic Operators and Bitwise Operators along with Relational Operators and Assignment Operators which all primitives can use.
Overflow and Underflow
Ints have the potential to overflow if an int tries to store a number larger than 2,147,483,647. If a number does overflow, it will wrap back around and continue adding from -2,147,483,648.
So if x
initially equals Integer.MAX_VALUE
and 1 is added to it, it will experience overflow and wrap around to Integer.MIN_VALUE
. x
will then equal -2,147,483,648.
If we instead added 2, the final result of x
is -2,147,483,647 or Integer.MIN_VALUE + 1
.
Underflow happens the same way but the exact opposite; numbers that are less than -2,147,483,648 are then wrapped back up to 2,147,483,647.
So if x
initially equals Integer.MIN_VALUE
and 1 is subtracted from it, it will experience underflow and wrap around to Integer.MAX_VALUE
. x
will then equal 2,147,483,647.
If we instead subtracted 2, the final result of x
is 2,147,483,646 or Integer.MAX_VALUE - 1
.
boolean
A boolean is a 1 bit primitive. Its purpose is to record whether something is true (1) or false (0). The following code defines a boolean.
boolean x;
By default, Java sets the value of x
to false (0). So, if x
were to be printed, it would print out "false".
To initalize it, use the assignment operator. This can also be done while the boolean is defined.
boolean x = true; // x is true x = false; // x is now false
Booleans are the only primitive that can use Logical Operators along with Relational Operators and Assignment Operators which all primitives can use.
char
A char is a 2 byte (16 bits) primitive that stores a integer that maps bijectively to an ASCII character. Below is a table of ASCII values:
Decimal | Hex | Oct | HTML | Char | Type |
---|---|---|---|---|---|
0 | 0x0 | 0_{8} | NUL (null) | Control | |
1 | 0x1 | 1_{8} | SOH (start of heading) | Control | |
2 | 0x2 | 2_{8} | STX (start of text) | Control | |
3 | 0x3 | 3_{8} | ETX (end of text) | Control | |
4 | 0x4 | 4_{8} | EOT (end of transmission) | Control | |
5 | 0x5 | 5_{8} | ENQ (enquiry) | Control | |
6 | 0x6 | 6_{8} | ACK (acknowledge) | Control | |
7 | 0x7 | 7_{8} | BEL (bell) | Control | |
8 | 0x8 | 10_{8} | BS (backspace) | Control | |
9 | 0x9 | 11_{8} | TAB (horizontal tab) | Control | |
10 | 0xA | 12_{8} | LF (NL line feed, new line) | Control | |
11 | 0xB | 13_{8} | VT (vertical tab) | Control | |
12 | 0xC | 14_{8} | FF (NP form feed, new page) | Control | |
13 | 0xD | 15_{8} | CR (carriage return) | Control | |
14 | 0xE | 16_{8} | SO (shift out) | Control | |
15 | 0xF | 17_{8} | SI (shift in) | Control | |
16 | 0x10 | 20_{8} | DLE (data link escape) | Control | |
17 | 0x11 | 21_{8} | DC1 (device control 1) | Control | |
18 | 0x12 | 22_{8} | DC2 (device control 2) | Control | |
19 | 0x13 | 23_{8} | DC3 (device control 3) | Control | |
20 | 0x14 | 24_{8} | DC4 (device control 4) | Control | |
21 | 0x15 | 25_{8} | NAK (negative acknowledge) | Control | |
22 | 0x16 | 26_{8} | SYN (synchronous idle) | Control | |
23 | 0x17 | 27_{8} | ETB (end of transmission block) | Control | |
24 | 0x18 | 30_{8} | CAN (cancel) | Control | |
25 | 0x19 | 31_{8} | EM (end of medium) | Control | |
26 | 0x1A | 32_{8} | SUB (substitute) | Control | |
27 | 0x1B | 33_{8} | ESC(escape) | Control | |
28 | 0x1C | 34_{8} | FS (file separator) | Control | |
29 | 0x1D | 35_{8} | GS (group separator) | Control | |
30 | 0x1E | 36_{8} | RS (record separator) | Control | |
31 | 0x1F | 37_{8} | US (unit separator) | Control | |
32 | 0x20 | 40_{8} |   | (space) | Printable |
33 | 0x21 | 41_{8} | ! | ! | Printable |
34 | 0x22 | 42_{8} | " | " | Printable |
35 | 0x23 | 43_{8} | # | # | Printable |
36 | 0x24 | 44_{8} | $ | $ | Printable |
37 | 0x25 | 45_{8} | % | % | Printable |
38 | 0x26 | 46_{8} | & | & | Printable |
39 | 0x27 | 47_{8} | ' | ' | Printable |
40 | 0x28 | 50_{8} | ( | ( | Printable |
41 | 0x29 | 51_{8} | ) | ) | Printable |
42 | 0x2a | 52_{8} | * | * | Printable |
43 | 0x2b | 53_{8} | + | + | Printable |
44 | 0x2c | 54_{8} | , | , | Printable |
45 | 0x2d | 55_{8} | - | - | Printable |
46 | 0x2e | 56_{8} | . | . | Printable |
47 | 0x2f | 57_{8} | / | / | Printable |
48 | 0x30 | 60_{8} | 0 | 0 | Printable |
49 | 0x31 | 61_{8} | 1 | 1 | Printable |
50 | 0x32 | 62_{8} | 2 | 2 | Printable |
51 | 0x33 | 63_{8} | 3 | 3 | Printable |
52 | 0x34 | 64_{8} | 4 | 4 | Printable |
53 | 0x35 | 65_{8} | 5 | 5 | Printable |
54 | 0x36 | 66_{8} | 6 | 6 | Printable |
55 | 0x37 | 67_{8} | 7 | 7 | Printable |
56 | 0x38 | 70_{8} | 8 | 8 | Printable |
57 | 0x39 | 71_{8} | 9 | 9 | Printable |
58 | 0x3a | 72_{8} | : | : | Printable |
59 | 0x3b | 73_{8} | ; | ; | Printable |
60 | 0x3c | 74_{8} | < | < | Printable |
61 | 0x3d | 75_{8} | = | = | Printable |
62 | 0x3e | 76_{8} | > | > | Printable |
63 | 0x3f | 77_{8} | ? | ? | Printable |
64 | 0x40 | 100_{8} | @ | @ | Printable |
65 | 0x41 | 101_{8} | A | A | Printable |
66 | 0x42 | 102_{8} | B | B | Printable |
67 | 0x43 | 103_{8} | C | C | Printable |
68 | 0x44 | 104_{8} | D | D | Printable |
69 | 0x45 | 105_{8} | E | E | Printable |
70 | 0x46 | 106_{8} | F | F | Printable |
71 | 0x47 | 107_{8} | G | G | Printable |
72 | 0x48 | 110_{8} | H | H | Printable |
73 | 0x49 | 111_{8} | I | I | Printable |
74 | 0x4a | 112_{8} | J | J | Printable |
75 | 0x4b | 113_{8} | K | K | Printable |
76 | 0x4c | 114_{8} | L | L | Printable |
77 | 0x4d | 115_{8} | M | M | Printable |
78 | 0x4e | 116_{8} | N | N | Printable |
79 | 0x4f | 117_{8} | O | O | Printable |
80 | 0x50 | 120_{8} | P | P | Printable |
81 | 0x51 | 121_{8} | Q | Q | Printable |
82 | 0x52 | 122_{8} | R | R | Printable |
83 | 0x53 | 123_{8} | S | S | Printable |
84 | 0x54 | 124_{8} | T | T | Printable |
85 | 0x55 | 125_{8} | U | U | Printable |
86 | 0x56 | 126_{8} | V | V | Printable |
87 | 0x57 | 127_{8} | W | W | Printable |
88 | 0x58 | 130_{8} | X | X | Printable |
89 | 0x59 | 131_{8} | Y | Y | Printable |
90 | 0x5a | 132_{8} | Z | Z | Printable |
91 | 0x5b | 133_{8} | [ | [ | Printable |
92 | 0x5c | 134_{8} | \ | \ | Printable |
93 | 0x5d | 135_{8} | ] | ] | Printable |
94 | 0x5e | 136_{8} | ^ | ^ | Printable |
95 | 0x5f | 137_{8} | _ | _ | Printable |
96 | 0x60 | 140_{8} | ` | ` | Printable |
97 | 0x61 | 141_{8} | a | a | Printable |
98 | 0x62 | 142_{8} | b | b | Printable |
99 | 0x63 | 143_{8} | c | c | Printable |
100 | 0x64 | 144_{8} | d | d | Printable |
101 | 0x65 | 145_{8} | e | e | Printable |
102 | 0x66 | 146_{8} | f | f | Printable |
103 | 0x67 | 147_{8} | g | g | Printable |
104 | 0x68 | 150_{8} | h | h | Printable |
105 | 0x69 | 151_{8} | i | i | Printable |
106 | 0x6a | 152_{8} | j | j | Printable |
107 | 0x6b | 153_{8} | k | k | Printable |
108 | 0x6c | 154_{8} | l | l | Printable |
109 | 0x6d | 155_{8} | m | m | Printable |
110 | 0x6e | 156_{8} | n | n | Printable |
111 | 0x6f | 157_{8} | o | o | Printable |
112 | 0x70 | 160_{8} | p | p | Printable |
113 | 0x71 | 161_{8} | q | q | Printable |
114 | 0x72 | 162_{8} | r | r | Printable |
115 | 0x73 | 163_{8} | s | s | Printable |
116 | 0x74 | 164_{8} | t | t | Printable |
117 | 0x75 | 165_{8} | u | u | Printable |
118 | 0x76 | 166_{8} | v | v | Printable |
119 | 0x77 | 167_{8} | w | w | Printable |
120 | 0x78 | 170_{8} | x | x | Printable |
121 | 0x79 | 171_{8} | y | y | Printable |
122 | 0x7a | 172_{8} | z | z | Printable |
123 | 0x7b | 173_{8} | { | { | Printable |
124 | 0x7c | 174_{8} | | | | | Printable |
125 | 0x7d | 175_{8} | } | } | Printable |
126 | 0x7e | 176_{8} | ~ | ~ | Printable |
127 | 0x7f | 177_{8} |  | DEL (delete) | Control |
Decimal | Hex | Oct | HTML | Char | Type |
---|---|---|---|---|---|
128 | 0x80 | 200_{8} | € | Ç | Extended |
129 | 0x81 | 201_{8} |  | ü | Extended |
130 | 0x82 | 202_{8} | ‚ | é | Extended |
131 | 0x83 | 203_{8} | ƒ | â | Extended |
132 | 0x84 | 204_{8} | „ | ä | Extended |
133 | 0x85 | 205_{8} | … | à | Extended |
134 | 0x86 | 206_{8} | † | å | Extended |
135 | 0x87 | 207_{8} | ‡ | ç | Extended |
136 | 0x88 | 210_{8} | ˆ | ê | Extended |
137 | 0x89 | 211_{8} | ‰ | ë | Extended |
138 | 0x8a | 212_{8} | Š | è | Extended |
139 | 0x8b | 213_{8} | ‹ | ï | Extended |
140 | 0x8c | 214_{8} | Œ | î | Extended |
141 | 0x8d | 215_{8} |  | ì | Extended |
142 | 0x8e | 216_{8} | Ž | Ä | Extended |
143 | 0x8f | 217_{8} |  | Å | Extended |
144 | 0x90 | 220_{8} |  | É | Extended |
145 | 0x91 | 221_{8} | ‘ | æ | Extended |
146 | 0x92 | 222_{8} | ’ | Æ | Extended |
147 | 0x93 | 223_{8} | “ | ô | Extended |
148 | 0x94 | 224_{8} | ” | ö | Extended |
149 | 0x95 | 225_{8} | • | ò | Extended |
150 | 0x96 | 226_{8} | – | û | Extended |
151 | 0x97 | 227_{8} | — | ù | Extended |
152 | 0x98 | 230_{8} | ˜ | ÿ | Extended |
153 | 0x99 | 231_{8} | ™ | Ö | Extended |
154 | 0x9a | 232_{8} | š | Ü | Extended |
155 | 0x9b | 233_{8} | › | ¢ | Extended |
156 | 0x9c | 234_{8} | œ | £ | Extended |
157 | 0x9d | 235_{8} |  | ¥ | Extended |
158 | 0x9e | 236_{8} | ž | ₧ | Extended |
159 | 0x9f | 237_{8} | Ÿ | ƒ | Extended |
160 | 0xa0 | 240_{8} |   | á | Extended |
161 | 0xa1 | 241_{8} | ¡ | í | Extended |
162 | 0xa2 | 242_{8} | ¢ | ó | Extended |
163 | 0xa3 | 243_{8} | £ | ú | Extended |
164 | 0xa4 | 244_{8} | ¤ | ñ | Extended |
165 | 0xa5 | 245_{8} | ¥ | Ñ | Extended |
166 | 0xa6 | 246_{8} | ¦ | ª | Extended |
167 | 0xa7 | 247_{8} | § | º | Extended |
168 | 0xa8 | 250_{8} | ¨ | ¿ | Extended |
169 | 0xa9 | 251_{8} | © | ⌐ | Extended |
170 | 0xaa | 252_{8} | ª | ¬ | Extended |
171 | 0xab | 253_{8} | « | ½ | Extended |
172 | 0xac | 254_{8} | ¬ | ¼ | Extended |
173 | 0xad | 255_{8} | ­ | ¡ | Extended |
174 | 0xae | 256_{8} | ® | « | Extended |
175 | 0xaf | 257_{8} | ¯ | » | Extended |
176 | 0xb0 | 260_{8} | ° | ░ | Extended |
177 | 0xb1 | 261_{8} | ± | ▒ | Extended |
178 | 0xb2 | 262_{8} | ² | ▓ | Extended |
179 | 0xb3 | 263_{8} | ³ | │ | Extended |
180 | 0xb4 | 264_{8} | ´ | ┤ | Extended |
181 | 0xb5 | 265_{8} | µ | ╡ | Extended |
182 | 0xb6 | 266_{8} | ¶ | ╢ | Extended |
183 | 0xb7 | 267_{8} | · | ╖ | Extended |
184 | 0xb8 | 270_{8} | ¸ | ╕ | Extended |
185 | 0xb9 | 271_{8} | ¹ | ╣ | Extended |
186 | 0xba | 272_{8} | º | ║ | Extended |
187 | 0xbb | 273_{8} | » | ╗ | Extended |
188 | 0xbc | 274_{8} | ¼ | ╝ | Extended |
189 | 0xbd | 275_{8} | ½ | ╜ | Extended |
190 | 0xbe | 276_{8} | ¾ | ╛ | Extended |
191 | 0xbf | 277_{8} | ¿ | ┐ | Extended |
192 | 0xc0 | 300_{8} | À | └ | Extended |
193 | 0xc1 | 301_{8} | Á | ┴ | Extended |
194 | 0xc2 | 302_{8} | Â | ┬ | Extended |
195 | 0xc3 | 303_{8} | Ã | ├ | Extended |
196 | 0xc4 | 304_{8} | Ä | ─ | Extended |
197 | 0xc5 | 305_{8} | Å | ┼ | Extended |
198 | 0xc6 | 306_{8} | Æ | ╞ | Extended |
199 | 0xc7 | 307_{8} | Ç | ╟ | Extended |
200 | 0xc8 | 310_{8} | È | ╚ | Extended |
201 | 0xc9 | 311_{8} | É | ╔ | Extended |
202 | 0xca | 312_{8} | Ê | ╩ | Extended |
203 | 0xcb | 313_{8} | Ë | ╦ | Extended |
204 | 0xcc | 314_{8} | Ì | ╠ | Extended |
205 | 0xcd | 315_{8} | Í | ═ | Extended |
206 | 0xce | 316_{8} | Î | ╬ | Extended |
207 | 0xcf | 317_{8} | Ï | ╧ | Extended |
208 | 0xd0 | 320_{8} | Ð | ╨ | Extended |
209 | 0xd1 | 321_{8} | Ñ | ╤ | Extended |
210 | 0xd2 | 322_{8} | Ò | ╥ | Extended |
211 | 0xd3 | 323_{8} | Ó | ╙ | Extended |
212 | 0xd4 | 324_{8} | Ô | ╘ | Extended |
213 | 0xd5 | 325_{8} | Õ | ╒ | Extended |
214 | 0xd6 | 326_{8} | Ö | ╓ | Extended |
215 | 0xd7 | 327_{8} | × | ╫ | Extended |
216 | 0xd8 | 330_{8} | Ø | ╪ | Extended |
217 | 0xd9 | 331_{8} | Ù | ┘ | Extended |
218 | 0xda | 332_{8} | Ú | ┌ | Extended |
219 | 0xdb | 333_{8} | Û | █ | Extended |
220 | 0xdc | 334_{8} | Ü | ▄ | Extended |
221 | 0xdd | 335_{8} | Ý | ▌ | Extended |
222 | 0xde | 336_{8} | Þ | ▐ | Extended |
223 | 0xdf | 337_{8} | ß | ▀ | Extended |
224 | 0xe0 | 340_{8} | à | α | Extended |
225 | 0xe1 | 341_{8} | á | ß | Extended |
226 | 0xe2 | 342_{8} | â | Γ | Extended |
227 | 0xe3 | 343_{8} | ã | π | Extended |
228 | 0xe4 | 344_{8} | ä | Σ | Extended |
229 | 0xe5 | 345_{8} | å | σ | Extended |
230 | 0xe6 | 346_{8} | æ | µ | Extended |
231 | 0xe7 | 347_{8} | ç | τ | Extended |
232 | 0xe8 | 350_{8} | è | Φ | Extended |
233 | 0xe9 | 351_{8} | é | Θ | Extended |
234 | 0xea | 352_{8} | ê | Ω | Extended |
235 | 0xeb | 353_{8} | ë | δ | Extended |
236 | 0xec | 354_{8} | ì | ∞ | Extended |
237 | 0xed | 355_{8} | í | φ | Extended |
238 | 0xee | 356_{8} | î | ε | Extended |
239 | 0xef | 357_{8} | ï | ∩ | Extended |
240 | 0xf0 | 360_{8} | ð | ≡ | Extended |
241 | 0xf1 | 361_{8} | ñ | ± | Extended |
242 | 0xf2 | 362_{8} | ò | ≥ | Extended |
243 | 0xf3 | 363_{8} | ó | ≤ | Extended |
244 | 0xf4 | 364_{8} | ô | ⌠ | Extended |
245 | 0xf5 | 365_{8} | õ | ⌡ | Extended |
246 | 0xf6 | 366_{8} | ö | ÷ | Extended |
247 | 0xf7 | 367_{8} | ÷ | ≈ | Extended |
248 | 0xf8 | 370_{8} | ø | ° | Extended |
249 | 0xf9 | 371_{8} | ù | ∙ | Extended |
250 | 0xfa | 372_{8} | ú | · | Extended |
251 | 0xfb | 373_{8} | û | √ | Extended |
252 | 0xfc | 374_{8} | ü | ⁿ | Extended |
253 | 0xfd | 375_{8} | ý | ² | Extended |
254 | 0xfe | 376_{8} | þ | ■ | Extended |
255 | 0xff | 377_{8} | ÿ | nbsp (Non-breaking space or no-break space) | Extended |
The following code defines a char.
char x;
By default, Java sets the value of all primitives to 0.
To initalize it, use the assignment operator. This can also be done while the char is defined.
int x = 65; // x is 'A' (ASCII code 65) x = 'g'; // x is now 'g' (ASCII code 103)
Only a certain range of chars can be printed out, on the ASCII table, it notes the printable ASCII codes.
Chars are one of a couple of primitives that can also use Arithmetic Operators and Bitwise Operators. However, the primitive type that they return is an int and will need to be cast into a char if needs to be kept as a char. It can also use the Relational Operators and Assignment Operators just like the other primitives.
Object
String
Integer
Boolean
Arrays
Variables
Functions
Recursion
Types of Errors
Scoring
Each problem specifies its own worth. No one problem can be worth more than 20% of the total score possible.