Page 93 - CA_Blue( J )_Class10
P. 93

•  Multiline Comments: These comments help to write more than one line comments so that the logic of the code can
                   be explained in detail. Multiline comments begin with "/*" and end with "*/". For example:
                    void natural()
                    {
                        int i;
                        for(i=1;i<10;i++)
                        {
                             /* This loop runs from 1 to 10 and prints the value of i. The value of i is
                              incremented by 1 after every iteration.  */
                            System.out.println(i);
                        }
                    }
                 •  Documentation Comments: These comments are used to write the documentation part of the program, such as
                   the questions about the program, the name of the programmer, etc., at the beginning of the program. They do not
                   depict the program logic. A documentation comment starts with "/**" and ends with "*/".
                   For example:
                    /**
                        Write a program to print the square and cube of 10.
                        Code written by: Partha Saha
                        Date: 09/07/2021
                    */
                    class cal
                    {
                        public static void main()
                        {
                            int a=10, sq, cu;
                            sq=a*a;
                            cu=a*a*a;
                            System.out.println("Square: " +sq);
                            System.out.println("Cube: " +cu);
                        }
                    }
                 When you run the preceding code, you will get the following output:
                 Square: 100

                 Cube: 1000



                                Let’s Revisit



                       ®  Initialization means to assign an initial value to a variable before using the variable in the program.
                       ®  We can take values using parameters passed to methods.
                       ®  The Scanner class is a predefined class in Java.
                       ®  An error is an abnormal condition that can stop the execution of a program or produce an abnormal output.
                       ®  There are three types of errors: syntax, logical and runtime errors.
                       ®  An exception is a situation in which the execution of a program stops abnormally.
                       ®  Comments are non-executable statements used to explain the code.




                                                                                                                       91
                                                                                                         Input in Java   91
   88   89   90   91   92   93   94   95   96   97   98