Page 114 - CA_Blue( J )_Class9
P. 114

C.  Answer the following questions.
                     1.  What are operators?
                    Ans.  Operators are symbols on which the operand works. In an expression, a + b : “+” is the operator.
                     2.  What are the three forms of operators?
                    Ans.  The three forms of operators are:
                       a.  Unary Operator
                       b.  Binary Operator
                       c.  Ternary Operator
                     3.  Define Arithmetic Unary Plus operator.
                    Ans.  The unary plus (+) operator works only on one operand. The output is the same value of the operand which is either
                       of an integer literal or real literal. The result of the unary plus operator may be positive or negative depending on the
                       values.
                     4.  Write the syntax of Ternary Operator.
                    Ans.  variable = (logical expression)? True part:  False part;
                     5.  Convert a+=5(shorthand operator) to Binary operator?
                    Ans.  a+=5 is equivalent to a=a+5.
                     6.  Explain three types of Logical Operator.
                    Ans.  Three types of logical operators in Java are:
                            The && Operator: This operator is known as “AND” or “Logical AND” operator The AND operator returns true only
                          if all conditions are true; otherwise conditions is false, the result will be false.
                            The  || Operator: This  operator is  known  as  “OR”  or “Logical  OR”  operator.  It is  also  used  for comparing  two
                          conditions. The outcome of this operator is true if any one of the conditions in the expression satisfies; and the
                          outcome is false only if all the conditions are false.
                            The ! Operator: This operator is known as “NOT” or “Logical NOT” operator. It is a unary operator because it works
                          only on one operand. The outcome of this operator is false, if the condition is satisfied and if the condition does not
                          satisfy, then the outcome of the operator is true. In other words, it reverses the output of the condition.
                     7.  Define Hierarchy of operator.
                    Ans.  “Hierarchy”  means  arranging  things  according  to  relative  significance.  For  example,  Grandfather  ->  Father  ->  Son,
                       Similarly, in expression some operators have higher precedence than other operators. So, their calculation is done
                       before the lower precedence operators. These are known as Hierarchy operators.
                     8.  Define precedence of operators.
                    Ans.  Precedence of Operators refers to the order in which the the operators will be evaluated in an expression. Java uses this
                       precedence when an expression contains two or more operators.  rows. The operators present in the same row in the
                       table showing precedence of operators, indicate the same order of preference and can be executed according to the
                       associativity of the operators.
                     9.   Write the hierarchy of Arithmetic operator.
                    Ans.  The Hierarchy of Arithmetic Operator are as follows:
                       1.  postfix unary
                       2.  Unary Operators
                       3.  * / %
                       4.  + -
                     10.   Define counter.
                    Ans.  A counter is a variable used to track how many times a particular part of code is executed. Counters are especially useful
                       in loops when counting iterations or specific occurrences. Generally, a counter variable is initialized to 0 (or 1 depending
                       on the context) and is incremented (usually by 1) each time the associated code block runs. It is crucial to initialize the
                       counter to avoid any unexpected or "garbage" values that could affect accuracy.







                   112    Touchpad Computer Applications-IX
   109   110   111   112   113   114   115   116   117   118   119