Syntax defines the rules by which a program must adhere to be processed by the compiler. Semantics defines the logical rules that make a computer program do what you want it to.
Computers represent data as a sequence of 1s and 0s.
A data type is a human-readable tag that represents a specific usage of a computer's memory.
A short is represented by two bytes while an int is represented by four bytes.
The first two statements are legal but the third is not because the result of adding two shorts is automatically converted to an integer; an explicit cast to a short is required for this statement to be correct:
short result = ( short )( s1 + s2 );
Arithmetic promotion means that a variable of a certain data type is automatically converted to a "wider" type during an arithmetic operation.
You can only assign a byte or a short to a short.
Casting is explicitly interpreting a variable as a more narrow type; the result of this is dropping bits from the variable. It is accomplished by prefacing the variable with the type to cast the variable to enclosed in parentheses:
int integer = 50; short s = ( short ) integer;
You define a variable to be a constant by prefacing its data type with the keyword final: