1/37
Flashcards for reviewing Java programming fundamentals, covering topics from program structure and tokens to variables, operators, and type conversions.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What are the parts of speech in a language like English, which can be compared to elements in a Java program?
Nouns, pronouns, adjectives, verbs, etc.
What is a token in Java?
The smallest unit that composes a Java program.
What are the five types of tokens in Java?
Keywords, Identifiers, Literals/Constants, Special Symbols/Punctuators, Operators
What are keywords or reserved words in Java?
Words reserved for a specific purpose in a programming language.
What are identifiers in Java?
User-defined words used to name classes, variables, and methods.
What are literals or constants in Java?
Values that do not change during the program's execution.
What are special symbols or punctuators in Java?
Characters or symbols used to separate or delineate parts of a program (e.g., [], (), {}, ;, :, =, #).
What are operators in Java?
Symbols that cause the compiler to take specific actions (e.g., +,
What characters can an identifier consist of in Java?
Letters, digits, underscores (_), and dollar signs ($). Must start with a letter, underscore, or dollar sign and cannot be a reserved word.
What is typically known as the standard output device in Java?
The console window that starts a Java application.
What is the standard input device in Java?
The keyboard.
What is used to send information to the standard output device in Java?
A Java class stored in the standard Java library.
What does the println method do in Java?
It places a newline character at the end of whatever is being printed out, moving the cursor to the next line.
How does the print statement differ from the println statement in Java?
It works similarly to println but does not add a newline character at the end of the output.
What is an escape sequence in Java?
A sequence of characters that represents a special character (e.g., \n for newline).
What are some common Java escape sequences and their meanings?
\n (newline), \t (tab), \b (backspace), \r (carriage return), \ (backslash), \' (single quote), \" (double quote).
What operator is used for string concatenation in Java, and what happens if it's used with a string?
The + operator. If either side is a string, the result will be a string.
What are the three characteristics of a space in memory?
Identifier, Data Type, and State.
What does 'variable' mean in programming?
Allocating a space in memory whose state (value) may change.
What does 'constant' mean in programming?
Allocating a space in memory whose state (value) cannot change.
What are the primitive data types in Java?
byte, short, int, long, float, double, char, boolean.
What are the steps for using variables and constants in Java?
Declare, Initialize, Use.
What is the syntax for declaring a variable in Java?
DataType VariableName;
What is the syntax for initializing a variable in Java?
DataType VariableName = Value; or DataType VariableName; VariableName = Value;
What is the syntax for declaring and initializing a constant in Java?
final DataType CONSTANTNAME = Value;
What are the rules for assignment and data types in Java?
Variables can only store values of their own type. Int values can be stored in a Double, but the value is converted to the equivalent real number. Doubles are not compatible with floats due to size/precision.
What does the E or e represent in scientific notation of floating-point literals?
Exponent, and it can be either in lowercase or uppercase.
What are some types of operators in Java?
Arithmetic operators, Augmented assignment operators, Increment/Decrement operators.
What are the arithmetic operators in Java?
How are expressions evaluated when parentheses are used in Java?
The inner most parenthesis are processed first. If two sets of parenthesis are at the same level, they are processed left to right.
What happens in integer division in Java?
It truncates any decimal remainder. For example, 5 / 2 yields 2.
What class needs to be imported to allow a program to read data values?
import java.util.Scanner;
What are the phases of the software development process?
Requirement Specification, System Analysis, System Design, Implementation, Testing, Deployment, Maintenance.
List some common errors and pitfalls in Java programming.
Undeclared/Uninitialized Variables and Unused Variables, Integer Overflow, Round-off Errors, Unintended Integer Division, Redundant Input Objects.
What is the result of an even number % 2
Always 0 and an odd number % 2 is always 1.
What code is missing in Line 2: Missing static for the main method.
public static void main(String[] args)
How do you write a statement to let the user enter a double value from the keyboard?
Use Scanner input = new Scanner(System.in); double value = input.nextDouble();
What happens if you entered 5a when executing the following code: double radius = input.nextDouble();
A runtime error will occur if you entered 5a when executing the following code: