Programming Basics
Outputting
Operators
Variables
Data Types
100
What does a compiler do?
Translates code into machine language
100
What is a command for outputting to the console?
System.out.println(); or System.out.print();
100
What are the symbols for addition, subtraction, multiplication, and division?
+, -, *, /
100
What is a variable?
A place-holder or storage container for a single value of information
100
Name a data type for whole numbers
short, long, int
200
What is bytecode?
Another name for "machine language"
200
What symbol is used to group/concatenate multiple pieces of information?
+
200
True or False: When dividing, the answer will always display the decimal if there is one.
False - The decimal is only displayed if one or more of the numbers you are dividing have been declared with decimals, or with the data type of "float" or "double" (not with "int").
200
When declaring a variable, you need two things. What are they?
Data type and a name
200
Name a data type for decimal numbers.
float, double
300
What is ASCII?
How letters and symbols are encoded in the computer. Essentially, it converts a byte of information into a single letter, number, or punctuation symbol.
300
What are two ways to begin outputting text on a new line?
Use System.out.println(), OR use the newline escape sequence "\n"
300
What does the increment operator do?
The increment operator (++) increases the variable by one. (x = x +1)
300
True or false: A variable is always initialized when it is declared.
False - Initialization refers to giving the variable a value, which does not necessarily happen when the variable is declared.
300
Why is String NOT a data type?
A String is a collection of characters, and because 'char' is the data type for characters, there is no need for String to be its own data type. It's a class, a reference type.
400
What is the difference between a bit and a byte?
Bit - a single binary digit
Byte - 8 bits
400
What are two commands used for outputting to the console?
System.out.print(); System.out.println();
400
Solve the following problem: 5 % 6
This is the mod operator. The answer is 5. 6 goes into 5 zero times, so there is 5 leftover. Remember! % returns the REMAINDER FROM DIVISION
400
Is this a legal variable assignment: x + y = 4. Why or why not?
This is not a legal variable assignment. Though the variables are on the left-hand side, there is more than one variable on the left-hand side, which makes this statement illegal.
400
What is the data type "boolean" used for?
To return a true or a false in response to certain programming structures, such as conditional statements (IF statements).
500
What is the difference between machine code, assembly code, and high-level programming languages?
Machine code - pure binary, 1's and 0's
Assembly code - some basic English functions that translate directly into machine code
High-level - no resemblance to machine code; advanced programming structures; closely resembles English
500
What is an escape sequence? What symbol do escape sequences always begin with?
Escape sequences are used to add some formatting to outputs, or to print typically ignored punctuation, such as ", or \. Escape sequences always begin with \
500
In this example, what do x and y both equal? int x = 8; int y = x--;
y = 7; x = 8;
500
There are four rules for identifying (naming) variables. What are they?
Cannot be a reserved word Can only consist of letters, numbers, _, $ Cannot begin with a number Case sensitive
500
Why are data types necessary?
Memory management - they let the computer know ahead of time how much memory it should set aside for your variable so that it doesn't accidentally overwrite pieces of it later, and so that your variable doesn't accidentally overwrite anything else in the computer.
M
e
n
u