Basic Operators


  1. What is the output of this program?

    public class operators_Example
    {
    public static void main(String args[])
    {
    int num1 = 10;
    int num2 = 20;
    int num3;
    num3 = num2 + num2 * num1 / num2 + num2;
    System.out.print(num3);
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Ans: 50


  1. Which of these statements are incorrect?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Ans: D
    Division operator, /, has equal precedence as of multiplication operator. In expression involving multiplication and division evaluation of expression will begin from right side when no brackets are used.



  1. What is the order of precedence (highest to lowest) of following operators?

    1. &
    2. ^
    3. ?:











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Ans: B


  1. What is the value stored in p in following lines of code?

    int p, q, r;
    p = 0;
    q = 1;
    p = q = r = 8;











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Answer : 8



  1. What should be expression1 evaluate to in using ternary operator as in this line?

    expression1 ? expression2 : expression3











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    The controlling condition of ternary operator must evaluate to boolean.