Module 2: Representing Infomation Flashcards
What are the two types of variables?
Reference and Primitives’
What is a print statement?
A print statement is how we get a command to print to our console.
What is a variable
Something that represents a piece of data. The value may or may not be known at the time of declaration (creation) and can be changed.
What is a Primitive?
A primitive is for storing simple values… int, float, double, long, boolean, char, byte, and short.
What is a reference variable?
A reference variable stars, a memory address of an object. We say that the variable “refers” to the object.
System.out.println();
Java method that lets us print out a line of output, followed by a newline to the user.
System.out.print();
Prints output without a newline
What is a data type?
Indicates the type of data, a memory, location (variable or named constant) can store.
What are the different data types in Java?
int, float, double, short, byte, boolean, long, and char…
String in Java is actually a non-primitive data type
Boolean
A single value of either TRUE or FALSE
char data type
Used to hold any single character
int data type
A primitive data type that represents integer values. Ranges from -2147483648 to 2147483648
float data type
Holds a floating point value of up to six or seven significant digits ID accuracy
double data type
Can hold a floating point value of up to 14 or 15 significant digits of accuracy
short data type
holds small integers from -32,768 to 32,767
byte data type
holds very small integers from -128 to 127
long data type
Holds very large integers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
What data type uses single quotes?
char
Anything with “” is considered?
A String
What is a literal?
A literal is the sequence of characters used in a program to represent a constant value. For example, ‘A’ is a literal that represents the value A of type char and 17L is a literal that represents the number 17 as a value of type long. A literal is a way of writing a value and should not be confused with the value itself.
What is an instance variable?
Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded. i.e. The values are not present until an object is created.
What is a local variable?
Variables are defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and it will be destroyed when the method has completed.
What does it mean to initialize a variable?
Have a value assigned to the variable. In other words to give it the first value the variable will hold as this value can be changed later in the application.
What does it mean to declare a variable?
To reserve the space in memory (ex: int x;). In other words to create a variable but do not assign it a value right away. You can initialize the variable later in the code.