Page 343 - Web Applications (803) Class 11
P. 343

Section B
                                                        (Subjective Type Questions)
                 A.  Short answer type questions:
                     1.  Name the two types of JavaScript code.
                   Ans.  Internal and external.
                     2.   Which attribute of the <SCRIPT> tag helps you include an external JavaScript file?   [CBSE Handbook]
                   Ans.  We can use the <SCRIPT> tag with the src attribute to incorporate an external JavaScript file.

                     3.  What is the difference in the outputs that you get when you use the following operators =,  == , and ===?   [CBSE Handbook]
                   Ans.  •  Using assignment operator (=), the operator assigns lvalue to rvalue.
                        •  The comparison operator double equals (==) compares values and returns result as true or false.
                        •  In JavaScript, === (Triple equals) is a rigid equality comparison operator that returns false for values that are not of the
                          same type. For equality, this operator does type casting. When we use === to compare 5 with “5”, JavaScript returns
                          false.
                     4.  Explain the use of the conditional operator with the help of an example.

                   Ans.  The conditional (ternary) operator takes three operands: a condition followed by a question mark (? ), an expression to
                       execute if the condition is true followed by a colon (:), and lastly an expression to execute if the condition is false.
                       Example: max_value= num1>num2? num1:num2

                     5.  Name the suitable function for the following tasks:
                          i.  Extract a string from within another string
                         ii.  A number is rounded down to its nearest integer
                         iii.  If string1 occurs within string2
                         iv.  Converts the value to a decimal number
                   Ans.    i.  substring( )

                         ii.  math.floor( )
                         iii.  substr( )
                         iv.  parseFloat( )
                     6.  Predict the output of the following:                                              [CBSE Handbook]
                          i.  if x = 24 and y = 3 then the output of x*=x/y is ......................
                         ii.  if x = 25 and y =3 then the output of x+=y is ......................
                         iii.  if x = 15 and y =3 then the output of x%y is ......................

                   Ans.    i.  192
                         ii.  28
                         iii.  0
                     7.  What happens when user clicks the Cancel button of the prompt dialog box?         [CBSE Handbook]
                   Ans.  After clicking the OK button, the prompt( ) method returns the value. It returns the input value if it is entered; otherwise,
                       if the user clicks the Cancel button, it returns null.
                     8.  What is the purpose of the confirm( ) method?
                   Ans.  This method is used to obtain confirmation from the user about an action. For example, if a user wants to delete something
                       or cancel a purchase on an online website, a dialog box will display asking the user to acknowledge the deletion or order
                       cancellation. Confirm method brings up a dialog box with a question mark icon, a question, and two buttons: OK and
                       Cancel.





                                                                      Introduction to Dynamic Websites Using JavaScript  341
   338   339   340   341   342   343   344   345   346   347   348