Page 112 - CA_Blue( J )_Class9
P. 112

Let’s Revisit


                        Operators are symbols to instruct the compiler to execute some operations.
                        An operator that works with only one operand is called unary operator.

                        An operator that works with two operands is called binary operator.
                        An operator that works with three operands or expressions is called ternary operator.
                        Arithmetic operators are used to perform basic and advanced mathematical operations on the operands which
                       are of primitive data types.
                        Relational operators compare two variables or expressions and return a boolean value either true or false as the
                       result.
                        Logical operators are used to check whether an expression is true or false.
                        The dot operator is used access the member of the class.
                        The new operator is used to create objects.
                        The hierarchy of operators also known as operator precedence determines the sequence in which operations are
                       performed in an expression.
                        Associativity determines the order in which operators of the same precedence are evaluated in an expression.







                                                              MIND DRILL





                       Solved Questions



                  A.  Tick ( ) the correct answer.
                      1.  What does the ternary operator do in Java?
                         a.  It allows multiple conditions to be evaluated simultaneously.
                         b.  It evaluates a condition and returns one of two values based on the result.
                         c.  It performs bitwise operations on two operands.
                         d.  It combines two strings into one.
                      2.  Given the expression int result = (a > b) ? a : b;, what does result hold if a is 5 and b is 3?
                         a.  result is 3                                b.  result is 5
                         c.  result is 8                                d.  The code will not compile.
                      3.  Which of the following is not a relational operator in Java?
                         a.  ==                                         b.  !=
                         c.  <=                                         d.  ++
                      4.  What will be the output of the following Java code?
                         int a = 10, b = 20;
                         boolean result = (a < b);
                         System.out.println(result);
                         a.  10                                         b.  20
                         c.  true                                       d.  false




                   110    Touchpad Computer Applications-IX
   107   108   109   110   111   112   113   114   115   116   117