Classes/Objects  «Prev  Next»


Lesson 1

Java Operators and Expression Statements

This module discusses how operators are a fundamental element from which Java expressions and statements are built. The certification exam recognizes the importance of operators and contains a number of questions that call upon your knowledge of them. However, this should not be a cause for concern. You have probably already used most of the operators that Java provides. This module will review these operators and point out any important aspects of them that you should master in preparation for the exam.

Module Objectives

This module will review your knowledge of Java operators, provide numerous examples of their use, and help you to satisfy the following exam objectives:
  1. Determine the result of applying any operator, including assignment operators and instanceof to operands of any type, class, scope, accessibility, or any combination of these.
  2. 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.
  3. In an expression involving the operators &, |, &&, ||, and variables of known values, state which operands are evaluated and the value of the expression.
In addition to the above, you will cover the topics of conversion, casting, operator precedence, and order of evaluation.


Building expressions using operands and operators

An expression consists of operands and operators. Operands are normally variable names or literals while operators act on operands. The following are examples of expressions:

int numberWheels = 4;
System.out.println("Hello");
numberWheels = numberWheels + 1;

There are several ways of classifying operators:
  1. Arithmetic
  2. Assignment
  3. Relational
  4. Logical complement
  5. Logical
  6. Conditional
  7. Bitwise

Expressions can be thought of as the building blocks of a program and are used to express the logic of the program