Page 111 - CA_Blue( J )_Class9
P. 111
2. int a=10, b=2, c=15;
a. (a>b) || (b==c) = (10>2) || (2==15) =true||false = true
b. ((a+b)>c) || (a>c) = (12>15) || (10>15) =false|| false = false
c. (a>b) && (b==c) = (10>2) && (2==15) =true&&false = false
d. ((a+b)>c) && (a>c) = (12>15) && (10>15) =false&& false = false
e. ! ((a/b)>c) = !((10/2)>15) =!(false) = true
f. !(a!=(c-b)) = !(10!=(15-2)) =!(true) = false
5.7 OUTPUT STATEMENT
The output statements used to display results or messages on the screen. The message should be written within
the parentheses, i.e., (). It has two forms: System.out.print(message) and System.out.println(message);.
The difference between these forms is that println moves the cursor to the next line after diplaying the message
while print places the cursor on the same line after the displaying the message.
System.out represents the standard output stream of the device where the program is running, and the println()
method displays the given string along with a line feed.
Notice the semicolon at the end of the System.out.println() statement, it terminates the statement. It is also
known as statement terminator terminator. The Java compiler ignores all whitespace and indents, so it is necessary
to use a semicolon to denote the end of a statement in Java.
Program 21 Write a program to find the 4th power of a number.
1 class Find4thpower
2 {
3 public static void main(String args[])
4 {
5 int num = 5;
6 System.out.println("4th power of " + num + " is: " + (num * num *
num*num));
7 }
8 }
You will get the following output:
Operators in Java 109

