Page 181 - ComputerScience_Class_11
P. 181

3.  Which operator uses the principle of ‘change before action’?
                       a.  Prefix operator                             b.  Postfix operator
                       c.  Both a and b                                d.  None of these
                    4.  What will be the output of (5>6) && (2>1)?
                       a.  True                                        b.  False
                       c.  Error                                       d.  None of these
                    5.  What is the data type returned by the OR(|) operator?
                       a.  boolean                                     b.  int
                       c.  double                                      d.  None of these
                    6.  What will be returned by (5!=5 || (1+2)==3)?
                       a.  False                                       b.  True
                       c.  5                                           d.  3
                    7.  Which one of the following logical operators holds the highest precedence?
                       a.  OR                                          b.  AND
                       c.  NOT                                         d.  None of these
                    8.  The output of 15<<3 is …………………. .
                       a.  100                                         b.  120
                       c.  15                                          d.  3
                    9.  In the mathematical expression, what rule is followed by Java?
                       a.  BEDMAS                                      b.  BODMAS
                       c.  MASBOD                                      d.  None of these
                    10.  Which of the following operators is higher in precedence?
                       a.  Ternary                                     b.  Shift
                       c.  Logical                                     d.  Relational

                 B.  Fill in the blanks.
                    1.  ………………… compare two variables or expressions and result in true or false.
                    2.  Conditional  Assignment  Operator  consists  of  3  operands  that  may  be  variable,  expression  or  constant.  It  is  also  known  as
                       ………………… .
                    3.  When a Conditional Assignment Operator is used under another, it is known as ………………… .
                    4.  ………………… is a relational operator which checks whether both the operands are equal or not.
                    5.  Java allows a way to represent some binary operators in a shorter way using shorthand assignment operators. They are known as
                       ………………….
                                            a   b
                    6.  The Java expression of  P =  +   is ………………….
                                           b 2  a 2
                    7.  ………………… operators deal with two operands.
                    8.  If k=10, l=20 , m; m = ++k + ++l * ++k will give ………………… .
                    9.  3>7 || 8<12 is ………………… .
                   10.  ………………… operator results in false if the operands are of the same value.

                 C.  Answer the following questions:
                    1.  Explain the difference between an arithmetic expression and an arithmetic statement in Java. Give examples.
                    2.  Describe the difference between prefix and postfix unary operators. Illustrate with examples and show the output.
                    3.  Elaborate on the types of bitwise operators in Java and show how &, |, ^ and ~ work with examples.
                    4.  State the rules for naming variables in Java.
                    5.  What is a ternary operator in Java? Write a nested ternary operator to find the largest among three numbers.
                    6.  Explain the difference between assignment operators and shorthand operators. Give one example of each.
                    7.  Spot the output and explain the result of the following Java code:
                        int a = 5, b;
                        b = a++ + ++a;
                        System.out.println(b);
                    8.  Explain the difference between assignment operators and shorthand operators. Give one example of each.



                                                                                            Variables and Expressions  179
   176   177   178   179   180   181   182   183   184   185   186