Section 5: Operators and Assignments


  • Determine the result of applying any operator (including assignment operators and instance of) to operands of any type class scope or accessibility or any combination of these.

  • 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 upon objects and primitive values of passing variables into methods and performing assignments or other modifying operations in that method.

Relevant Sections

Read Chapter 3. The subsection "Object Value Equality" in Section 3.10 is not covered by the objectives. See also subsection "Reference Casting and instanceof Operator" in Section 6.6.

Study Notes

Operators require operands of certain types. The operands used with an operator influence which conversions can occur, and determine the type of the resulting expression. Some operators, such as + , can be applied to non-numeric values. Some operators are related , such as >> and >>> , and , & and && , but their behaviors are different.

There are several forms of conversions, and all except for casts occur implicitly depending on the context. The key to casting and conversion is to know the rules for widening numeric promotion, narrowing conversion, and conversion of references up and down the inheritance hierarchy (upcasting and downcasting ). The instanceof operator returns true if an object can be cast to the given reference type.

Some operators exhibit short-circuit behavior, which means that some operands may never be evaluated.

Parameters are passed by value. Methods get their own copy of the argument values. This holds for values of primitive data types, as well as for reference values denoting objects. Objects themselves are not passed as arguments.



A Programmer[ap]s Guide to Java Certification
A Programmer[ap]s Guide to Java Certification
ISBN: 201596148
EAN: N/A
Year: 2003
Pages: 284

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net