Page 75 - Viva ICSE Computer Studies 8 : E-book
P. 75
Learn More
A public access allows the method to be executed from another class, while a private access allows the
method to be executed only from the current class.
Do and Learn
Write a program to illustrate the use of increment and decrement operators.
Steps to be Followed
/* Program to do arithmetic calculation */
public class IncDec
{
public static void main(String arg [ ])
{
int a = 10;
int b = 20;
int c, d;
c = a++;
d = b––;
System.out.println(“a = “+ a);
System.out.println(“b = “ + b);
System.out.println(“c = “ + c);
System.out.println(“d = “ + d);
}
} Output
Computer Etiquette
While writing a program, the statements should be properly indented so that you can understand the
program easily.
63