Ch 3 - Expressions Flashcards
What is an expression composed of
Terms and Operators
A variable has three important attributes
Name, value, type
Names in Java are called?
Identifiers
What is a variable?
a placeholder for a value. A box with a label attached to the outside
Syntax for declarations
type identifier = expression(initial value);
Local Variable
Variables declared inside a method
Instance Variables or ivars
Variables declared within a class but outside of any method and are stored as part of each object
class variables
Class variables are associated with all objects of a particular class and not with individual objects
What is the private keyword
indicates that it can only be used within the class that defines it
What is the final keyword
Declares that the value will not change after the variable is initialized
type cast syntax
int n = (int) 1.9999;
type cast example
int feet = (int) (total inches/inches_per_foot);
How do you assign a new value to a variable
Assignment statement
balance += deposit;
Add deposit to balance
x++;
x += 1;