Page 137 - Computer science 868 Class 12
P. 137
The table given below lists the different reserved words or keywords used in Java.
abstract continue for new switch
assert default goto package synchronized
boolean do if private this
break double Implements protected throw
byte else import public throws
case enum instanceof return transient
catch extends int short try
char final interface static void
class finally Longlong strictfp volatile
const float native super while
4.10 COMMENTS
Comments are the statements in the program code which are non-executable. They are generally added for the users
to understand the program and its logic. They also make the debugging process easy for the users. They are usually of
three types which are discussed below:
• Single-Line Comments: The comments which exist in one line only are called single-line comments. They may be
written in a fresh line or after the end of the executable statement, i.e., after the semicolon (“;”). They begin with a
double slash (“//”) sign. They are used for the short explanation of the code.
For example,
System.out.println("Area :" + area); // Prints the area of a rectangle
• Multiline Comments: The comments which exist in more than one line are called multiline comments. They help to
explain the logic of the program code in detail. They begin with a “/*” sign and end with a “*/” sign.
For example,
/*The below program code is written to print
the sum of all the natural numbers starting from 1 to 10.*/
int i, s=0;
for(i=1; i<=10; i=i+1)
{
s=s+i;
}
System.out.println("Sum : "+s);
• Documentation Comments: The comments which are used to write the documentation part of the program are
called documentation comments. They include comments about the question/objective of the program, the name
of the programmer, etc. We do not write the program logic here. They start with a “/**” sign before the comment
and end with a “*/” sign.
For example,
/** Write a program to print the twice and thrice of a number;
Code written by: Partha Saha
Date: 14/08/2022 */
class documentation_comment
{
public static void main(int n)
{
int tw, th;
tw=n*2;
th=n*3;
135
Programming in Java 135

