Chapter 2: Elementary programming Flashcards
Data type
specifies the type of value stored in a variable(int, string, boolean, etc.)
Fundamental type
represents numbers, characters, and Boolean values
Variable
represents a stored value in a computers memory
Pseudocode
nature language + coding syntax(in this case Java)
double
used to declare a floating point number
char
used to declare a single character value such as “A”, “b”
String
used to declare multiple characters. like a sentence
What is a java object
A Java object is an instance of a class. Meaning that objects are formed under classes and have an identity, behavior, and a state.
import java.util.*;
Wildcard Import. imports all the classes in a package by using the asterisk as the wildcard.
Scanner input = new Scanner(System.in)
creates a Scanner object and assigns its reference to the variable ‘input’.
prompt
something that directs a user to enter input. A program should always tell a user what to enter when expecting input from the keyboard.
double radius = input.nextDouble();
this line will read the number (hopefully a number) inputed by the user and assign the value to ‘radius’.
IPO
Stands for input, process, and output and are the typical three steps for most simple programs in the text.
Wildcard import
imports all classes in the package by using the asterisk as the wildcard
Specific import
imports a specific/single class.
the correct method to read a real number is with a scanner object labeled ‘input’ is…
input.nextDouble()
identifiers
names of varaibles, classes interface, or packages
Identifiers must follow what rules?
- sequence of characters that consists of letters, digits, underscores, and dollar signs.
- an identifiers cannot start with a digit.
- Cannot be a reserve word
- Can be any length
Evaluate the statement:
“Every letter in a Java keyword is lowercase.”
True.
Which of the following are correct names for variables according to Java naming conventions?
- radius
- Radius
- RADIUS
- findArea
- FindArea
1 and 4.
Single word variables are in lowercase while multiple word variables follow “camelNamingConvention” in which the first word is lowercasae and the subsequent words have their first letter capitalized.
Constant
Represents a permanent data that never changes.
Constants are also known as what in Java…
Final ‘Variable’