Section 5: Operators and Assignments ( Chapter 3 )


Section 5: Operators and Assignments (Chapter 3)

  • 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.

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

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 converting 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.

In addition to the == operator, objects have the equals() method that can be used to compare objects. The == operator and the default equals() method consider every object to be unique. Classes can provide implementations of the equals() method that are less discriminatory. Correct implementation of the equals() must be understood .

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