Professional Documents
Culture Documents
Handout 2
Handout 2
Handout 2
Variables
Symbol used in a program that stands for a value or data stored in a computer’s memory
Identifiers whose values can be changed
o Local Variables – variables can only be used in the methods which there are declared
o Global Variables – variables used by any methods within the class or program
Constant
Fixed value used in certain mathematical or programming contexts
Operand
Constant, variable, or expression which an operator will act upon
Expression
Statement that is composed of at least one operator and one operand; it evaluates to a particular value on the result
of the operation
Operator
Action that is applies on the operand/s, resulting in some value; symbol that represents actions or computations to
be performed
o Assignment Operator (=)
This operator only assigns value to an operand
o Mathematical Operator (+, -, /, *, %)
It symbolizes in arithmetic
o Increment (++) and Decrement (--)
These operators only increment or decrement a value of an operand
o Relational Operator (==, !=, >, <, >=, <=)
These operators perform a comparison test between variables and constant
o Logical Operator (&&, ||, !)
These operators further expand the relational operator since they add more control to it
Operator Precedence Rule
Hierarchy that determined the sequence at which the operator in a given compound expression (two or more
operators) are to be performed
Comments
Are lines of codes that are not executed during the program
They are used to label a specific line of code
o Single Line Comment uses double slash(//)
It comments only one line
o Multi Line Comment uses slash-asterisk and asterisk-slash
It comments several lines
Statements
Is an instructional code that commands the computer to do a certain action upon its execution and it must be
terminated by a semicolon (;)
Data Types
Integer (int)
o Variable that holds positive or negative whole numbers
Character (char)
o Variable that holds a single character (one byte), which may be a number, a letter, or a symbol
Boolean (bool)
o Is a logical data type with only two values which is “True” or “False”
Float (float)
o Numbers with decimal parts
String
o A data type that supports all kind of text
Keyword
Reserved words in a programming language that have specific uses
These are the keywords used in Java: