Page 95 - CA_Blue( J )_Class10
P. 95

6.  ………………… comments are used to write one line comments.
                    7.  ………………… comments help to write more than one line comments.
                    8.  The compiler will not allow the program to execute if any ………………… error has occurred.

                    9.  If there is no main() method in a code, a  temporary………………… of object name is created to execute.
                   10.  A ………………… comment starts with "/**".

                  Answers
                     1.  java.util       2.  nextDouble()      3.  float          4.  try              5.  catch
                     6.  Single line     7.  Multiline         8.  Syntax         9.  Instance        10.  Documentation


                 C.  Answer the following questions:
                    1.  Define documentation comments.
                   Ans.  These comments are used to write the documentation part of the program, such as questions about the program, the name of
                       the programmer, etc., at the beginning of the program.
                    2.  What is the difference between Single line comments and Multiline comments?
                   Ans.
                                 Single Line Comment                   Multiline Comment
                       These comments are used to write one line   These comments help to write more than
                       comments.                             one line comments.
                       It begins with "//".                  It begins with "/*" and ends with "*/".
                    3.  Define runtime error. Give one example.
                   Ans.  The errors that occurred during the execution of a successfully compiled program are called runtime errors. Generally, these
                       errors occurred whenever a user enters wrong data or some data that is not required.
                        For example:

                       public class RuntimeErrorExample
                       {
                       public static void main(String[] args)
                       {
                       int result = 5 / 0;
                       System.out.println(result);
                       }
                       }
                    4.  Define the "try" block.
                   Ans.  "try" is a block where those statements are written which may produce some error and Java will throw an exception for those
                       errors.
                    5.  Define exception.
                   Ans.  An exception is a situation in which the execution of a program stops abnormally.
                    6.  What is the Scanner class?
                   Ans.  The Scanner class is a predefined class used to take input from the user.
                    7.  What do you mean by initialization?
                   Ans.  Initialization means to assign an initial value to a variable before using the variable in the program.
                    8.  What do mean by an error?
                   Ans.  An error is an abnormal condition that can stop the execution of a program or produce an abnormal output.
                    9.  Which statement is used to handle exceptions in Java? Give syntax.
                   Ans.  The try-catch statement is used to handle exceptions in Java. Syntax is:
                      try
                      {
                      }


                                                                                                                       93
                                                                                                         Input in Java   93
   90   91   92   93   94   95   96   97   98   99   100