Domanda |
Risposta |
inizia ad imparare
|
|
An expression is a combination of values, variables, operators and function calls. Expressions perform operations on data and move data around
|
|
|
how many oprands does a unary operator have? inizia ad imparare
|
|
1 eg E.g., the “minus” operator. - b where “-” is operator, and b operand
|
|
|
how many oprands does a binary operator have? inizia ad imparare
|
|
[1] A binary operator has two operands E.g., +, -, *, /... [2] In most languages, binary operators are infix, which means they appear between their operands [3] There are also operators that are prefix, i.e., they precede their operands.
|
|
|
What are the typical rules of precedence inizia ad imparare
|
|
[1] Parentheses: “(” “)” [2] Unary operators “++”, “--” [3] Unary operators “+” “-” [4] Binary operators “*”, “/” [5] Binary operators: “+” “-”
|
|
|
explain Operator Associativity Rules inizia ad imparare
|
|
The operator associativity rules for expression evaluation define the order in which “adjacent” operators of the same precedence levels are evaluated
|
|
|
when does and expression have side effects inizia ad imparare
|
|
We say an expression has a side effect if, in addition to return a value, it also modifies variables or causes something else to happen.
|
|
|
what is the genral syntax of the Assignment operator inizia ad imparare
|
|
<target_var> <assign_operator> <expression>
|
|
|
what are Compound Assignment Operators inizia ad imparare
|
|
[1] Compound means combining assignment with arithmetic operators. [2] It is a shorthand method of specifying a commonly needed form of assignment. [3] eg a = a + b writen as a += b
|
|
|
what is a Unary Assignment Operators inizia ad imparare
|
|
[1] Unary assignment operators in C-based languages combine increment and decrement operations with assignment eg count++ (count incremented by 1, i.e., count = count+1)
|
|
|
inizia ad imparare
|
|
Cast refers to type conversion that is explicitly requested by the programmer.
|
|
|
inizia ad imparare
|
|
[1] Coercion is an implicit type conversion that is initiated by the compiler. [2] The compiler checks the type compatibility of the assignment and changes the type of right side of the assignment.
|
|
|
what is a widening conversion inizia ad imparare
|
|
A widening conversion is one in which an object is converted to a type that allow any possible value of the original data (i.e., converting to a type takes a larger memory space)
|
|
|
what is A narrowing conversion inizia ad imparare
|
|
[1] usually done explicitly as a request from the programmers [3]e. g Java can convert int to short one needs to process the int value in a method design to work with short values. [4] The conversion is not safe (overflow may happen).
|
|
|
what are Relational operators inizia ad imparare
|
|
[1] Relational operator is a binary operator that compare the values of its operands and the result is a Boolean value True or False. [2] eg “Not Equal” operator could be one of these:!=,/=, ~=,. NE. or <>.
|
|
|
what is Short Circuit Evaluation inizia ad imparare
|
|
[1] expression eval' where the result is determined w/out eval'ng all of the operands and/or operators [2] (a>=0)&&(b<10) if (a<0), because (False && (b<0))is False for all value of b. Therefore, there is no need to evaluate (b<0)
|
|
|