Page 94
Monday, October 30th, 2006[ Team LiB ] Page 95
Note: If you are looking for best hosting provider to host and run your tomcat application check Astra tomcat hosting services
[ Team LiB ] Page 95
Note: If you are looking for best hosting provider to host and run your tomcat application check Astra tomcat hosting services
Page 93
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services
[ Team LiB ] Page 91
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services
[ Team LiB ] 3.4 Simple Assignment Operator = The assignment statement has the following syntax:
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services
Page 90
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp hosting services
[ Team LiB ] 3.3 Conversions In this section we discuss the different kinds of type conversions and list the contexts in which these can occur. Some type conversions must be explicitly stated in the program, while others are done implicitly. Some type conversions can be checked at compile time to guarantee their validity at runtime, while others will require an extra check at runtime. Unary Cast Operator: (type) Java, being a strongly typed language, checks for type compatibility (i.e., checks if a type can substitute for another type in a given context) at compile time. However, some checks are only possible at runtime (for example, which type of object a reference actually denotes during execution). In cases where an operator would have incompatible operands (for example, assigning a double to an int), Java demands that a cast be used to explicitly indicate the type conversion. The cast construct has the following syntax: (
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp hosting services
[ Team LiB ] 3.2 Evaluation Order of Operands In order to understand the result returned by an operator, it is important to understand the evaluation order of its operands. Java states that the operands of operators are evaluated from left to right. Java guarantees that all operands of an operator are fully evaluated before the operator is applied. The only exceptions are the short-circuit conditional operators &&, ||, and ?:. In the case of a binary operator, if the left-hand operand causes an exception (see Section 5.5, p. 181), the right-hand operand is not evaluated. The evaluation of the left-hand operand can have side effects that can influence the value of the right-hand operand. For example, in the following code: int b = 10; System.out.println((b=3) + b); the value printed will be 6 and not 13. The evaluation proceeds as follows: (b=3) + b 3 + b b is assigned the value 3 3 + 3 6 The evaluation order also respects any parentheses, and the precedence and associativity rules of operators. Examples illustrating how the operand evaluation order influences the result returned by an operator, can be found in Sections 3.4 and 3.7. [ Team LiB ] Page 88
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp hosting services
[ Team LiB ] Page 87
Hint: If you are looking for very good and affordable webspace to host and run your java hosting application check Virtualwebstudio java web hosting provider
[ Team LiB ] 3.1 Precedence and Associativity Rules for Operators Precedence and associativity rules are necessary for deterministic evaluation of expressions. The operators are summarized in Table 3.1. They are discussed in subsequent sections in this chapter. The following remarks apply to Table 3.1: . The operators are shown with decreasing precedence from the top of the table. . Operators within the same row have the same precedence. . Parentheses, ( ), can be used to override precedence and associativity. . The unary operators, which require one operand, include the postfix increment (++) and decrement (–) operators from the first row, all the prefix operators (+, -, ++, –, ~, !) in the second row, and the prefix operators (object creation operator new, cast operator (type)) in the third row. . The conditional operator (?
is ternary, that is, requires three operands. . All operators not listed above as unary or ternary, are binary, that is, require two operands. . All binary operators, except for the relational and assignment operators, associate from left to right. The relational operators are nonassociative. . Except for unary postfix increment and decrement operators, all unary operators, all assignment operators, and the ternary conditional operator associate from right to left. Table 3.1. Operator Summary Postfix operators [] . (parameters) expression++ expression– Unary prefix operators ++expression –expression +expression -expression ~ ! Unary prefix creation and cast new (type) Multiplicative * / % Additive + - Shift << >> >>> Relational < <= > >= instanceof Equality == != Bitwise/logical AND & Page 86
Hint: If you are looking for very good and affordable webspace to host and run your java hosting application check Virtualwebstudio java web hosting provider
[ Team LiB ] Chapter 3. Operators and Assignments Exam Objectives . Determine the result of applying any operator (including assignment operators and the instanceof operator) to operands of any type, class, scope, or accessibility, or any combination of these. o See also Section 6.6. . Determine the result of applying the boolean equals(Object) method to objects of any combination of the classes java.lang.String, java.lang.Boolean and java.lang.Object. . In an expression involving the operators &, |, &&, ||, and variables of known values, state which operands are evaluated and the value of the expression. . Determine the effect on objects and primitive values of passing variables into methods and performing assignments or other modifying operations in that method. Supplementary Objectives . Understand the operator precedence and associativity rules. . Distinguish between conversions involving casting, widening numeric conversions, and narrowing numeric conversions. . State unary numeric promotion and binary numeric promotion rules and the contexts in which they are applied. . Understand type conversions for primitive data types on assignment, string concatenation, arithmetic expression evaluation, and method invocation. [ Team LiB ] Page 85
Hint: If you are looking for very good and affordable webspace to host and run your java hosting application check Virtualwebstudio java web hosting provider