Class Notes: Part 4

5. What are expressions?
Expressions are constitutes by operators and operands to perform an operation. Based on the operators used, there are different types of expressions like ,
i). Arithmetic expressions Arithmetic expressions are also divided into
a). Integer expression :All operands in the expressions are integers. An integer expression yields an integer result.
b). Floating point (decimal ) expression: All operands in the expression are floating points(decimals).A floating point expression yields a floating point result.
ii). Relational expression ; The relational expression consists of relational operators. They are also called conditions.
iii). Logical expression : A logical expression is an expression whose value is either True or False.
For example x>y is a logical expression, since it can be either ‘True’ or ‘False’.
 
6. What is type conversion?
Type conversion means converting one data type to another data type. There are two types of type conversion, Implicit type conversion (Type Promotion) and Implicit type conversion(Type Casting)
a). Implicit type conversion also known as automatic type conversion is performed by the compiler. The conversion is always from lower type to higher type, it is also known as type promotion.
b) Explicit type conversion Type casting refers to conversion that is performed explicitly using cast operator. The operator used for this purpose is known as cast operator. The cast operator takes on the format cast type (expression)
eg. int a = (int) 10.5 , Here the value 10.5 is converted to integer type

Comments