Page 176 - ComputerScience_Class_11
P. 176

7.  What will be the output of the following program snippet?
                     int c=(5<4)? ((2==4)? 5: 4) : 6+5;
                    a.  5                                           b.  4
                    c.  6                                           d.  11
                  8.  Which bitwise operator returns false when both the results are false?
                    a.  Bitwise AND (&)                             b.  Bitwise OR (|)
                    c.  Bitwise NOT (!)                             d.  Bitwise Complement (~)
                  9.  What is the result of 10 | 8?
                    a.  2                                           b.  5
                    c. 10                                           d.  7
                 10.  What is the operator >> called?
                    a.  Bitwise signed right shift operator         b.  Bitwise signed left shift operator
                    c.  Bitwise unsigned left shift operator        d.  Bitwise unsigned right shift operator
                Answers
                  1.  b      2.  d    3.  a     4.  c     5.  d     6.  c     7.  d     8.  a     9.  c     10.  a


              B.  Fill in the blanks.
                  1.  ………………… must start with a letter or an underscore (_) or a dollar ($) sign.
                  2.  We ………………… change the value of the final variable.
                  3.  ………………… works the same as val=val-1.
                  4.  When the unary decrement operator is placed before the operand, then it is known as the ………………… .

                  5.  The operator which is used to find the remainder between two operands is known as ………………… .
                  6.  A ………………… is a tabular representation that displays the input and output bits when the bitwise operators &, |, ! are used.
                  7.  The output of  5 ^ 3 is ………………… .
                  8.  ………………… is used to shift bits of the first operand to the right or left one by one.

                Answers
                  1.  Variable names   2.  cannot            3.  val--         4.  “Prefix Unary decrement Operator”
                  5.  % (Modulus)      6.  truth table       7.  6             8.  Shift Operator



              C.  Answer the following questions:
                  1.  Name the three types of arithmetic operators used in Java.
                Ans.  The three types of arithmetic operators are unary, binary and ternary.
                  2.  Name the different types of unary operators.
                Ans.  There are different types of unary operators. They are Unary (+), Unary (-), Unary increment (++) and Unary decrement (--).
                  3.  What is the difference between a binary operator and a unary operator?
                Ans.  A binary operator works on two operands, while a unary operator works on a single operand.
                  4.  What does the final keyword do in Java?
                Ans.  The final keyword is used to make a variable constant, meaning its value cannot be changed after initialisation.
                  5.  Explain the use of the && operator in Java.
                Ans.  The && operator is a logical AND operator that returns true if both conditions are true.
                  6.  Explain the different categories of operators in Java.
                Ans.  In Java, there are mainly three categories of operators which are as follows:
                     •  Unary operator: A unary operator works only on one operand.
                     •  Binary operator: As the name suggests, a binary operator works on two operands.
                     •  Ternary operator: A ternary operator works on three operands.



                  174  Touchpad Computer Science (Ver. 3.0)-XI
   171   172   173   174   175   176   177   178   179   180   181