Preview

Explain Various Operator in Java, Also Comment How They Are Different from C++.

Powerful Essays
Open Document
Open Document
1312 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Explain Various Operator in Java, Also Comment How They Are Different from C++.
explain various operator in java, also comment how they are different from c++.
Operators
After having seen the basic types in Java and how to declare variables of each type, we are now going to show what basic operations can be performed with and on variables of the basic types.
Below is a table summarizing Java operators organized by the type of operation the operator is used for.
There are 8 types of operator that is follow :-
1 )- Arithmetic Operators
2)- Logic Operators
3)- Bitwise Operators
4)- Assignment Operators
5)- The Conditional Operators
6)- Increment and decrement operators
7)- Special operator
8)- Relational operator

Description of these operators :-
Arithmetic Operators
The arithmetic operators -, +, * and / can be used to perform respectively subtraction, addition, multiplication and division with integers and reals.
Example :-
1
2 int result = 3 * 56; double answer = 3.14 + 2.72;
Logic Operators
The logic operators &&, ||, ! and ^ can be used to perform respectively logical and, or, not and exclusive-or on boolean operands.
Example:
1
2 System.out.println(true || false); /* outputs true */
System.out.println(! true); /* outputs false */
Bitwise Operators
The bitwise operators &, |, ^, ~, and >>> can be used to perform bitwise and, or, exclusive-or, negation, left shift and right shift on integer operands. Note that there are two types of right shift: >> and >>>. The difference being that >> copies the sign bit into the high-order positions and >>> copies zeros into the high-order positions.
Example:
1
2 System.out.println(12 & 5); /* outputs 4 because 1100 & 0101 = 0100 = 4 */
System.out.println(3 >= all require a location (a variable) on the left side and an expression of the same type (or one that could be promoted to the same type) on the right side.
The basic assignment operator = evaluates the expression on the right and stores the resulting value in the location on the

You May Also Find These Documents Helpful

  • Satisfactory Essays

    USA TEST PREP ANSWER MATH

    • 1491 Words
    • 6 Pages

    This property allows you to change the order of the terms when adding OR multiplying without changing the outcome.…

    • 1491 Words
    • 6 Pages
    Satisfactory Essays
  • Satisfactory Essays

    cout << "Select the operator you want to work (+ for addition, - for subtraction , * for multiplication , / for division):- ";…

    • 426 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    There is nothing wrong with this discussion question response. Accordingly, I awarded the author a score of 10. Each paragraph is written to explain each operator. Clearly, this is good writing. Each paragraph uses vocabulary from the reading material, and gives insight into the operation of each operator. This response explains the unary operator “++” is used for adding one to a variable, the conditional-and-operator “&&” is used between testing expressions, the inequality operator ”!=” is used to rule out a possible value, and the “%=” operator is used to return the remainder of a division operation( to the variable to the left of this assignment operator ). Thank…

    • 110 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    Nt1310 Unit 1 Quiz

    • 1980 Words
    • 8 Pages

    6 . For an unconditional approach to a particular part of a complex PL/SQL block, which of the following control structures can be used?…

    • 1980 Words
    • 8 Pages
    Good Essays
  • Powerful Essays

    If > denotes +, < denotes –, + denotes  , Λ denotes x, – denotes =, x denotes > and =…

    • 1942 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    Homework Unit 3

    • 354 Words
    • 2 Pages

    4. AND operator- combines more than one condition in a program. Makes a compunf Boolean operation.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    ● Converts the value of i to double and stores it in d. This conversion is done automatically by the compiler, because double data type is normally wider than int, there is absolutely no risk storing int in double.…

    • 2338 Words
    • 10 Pages
    Powerful Essays
  • Satisfactory Essays

    unit 5 assignment 1

    • 423 Words
    • 3 Pages

    6. When determining if a number is within a range, the OR operator would be best to use.…

    • 423 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    b) Convert -124 to its binary representation: -12410 = -011111002. Using the second method for negative numbers, invert and then add 1.…

    • 1112 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    Ap Calculus

    • 2722 Words
    • 11 Pages

    | A cell reference that refers to cells by their fixed position in a worksheet; an absolute cell reference remains the same when the formula is copied.…

    • 2722 Words
    • 11 Pages
    Powerful Essays
  • Powerful Essays

    Java Chapter 2 Quiz

    • 2047 Words
    • 9 Pages

    4. The ____ is normally considered the standard output and standard input devices, and usually refer to…

    • 2047 Words
    • 9 Pages
    Powerful Essays
  • Satisfactory Essays

    Maths Order of Operation

    • 291 Words
    • 2 Pages

    Why is it important to follow the order of operations? What are some possible outcomes when the order of operations is ignored? If you invented a new notation where the order of operations was made clear, what would you do to make it clear?…

    • 291 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    W8 Comp

    • 898 Words
    • 4 Pages

    1) Which one of the following Windows NET commands options is NOT used to control services with the NET ????? ServiceName? (Points : 5)…

    • 898 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Doc. Unix

    • 1228 Words
    • 5 Pages

    b. It is used to perform division on the results of a numerical command operator.…

    • 1228 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Java Editor

    • 6650 Words
    • 27 Pages

    The programmer doesn’t need to remember all the keywords provided by Java language. One just has to provide the initial character of the keyword and he could get what he wants.…

    • 6650 Words
    • 27 Pages
    Satisfactory Essays

Related Topics