Home Tutorial Java Scjp Part5 SCJP Module-5 Question-3

 
 

SCJP Module-5 Question-3
Posted on: July 12, 2010 at 12:00 AM
The program given below will test your basic understanding of Java program and used of modulus operator in a program.

Given a sample code:

1    public class Sample {
2    public static void main(String args[]) {
3    int i = 1, j = 2;
4    i++;
5    j--;
6    if (i % j > 1)
7    i++;
8    System.out.println("i = "+i+ " j = "+j);
}}

What will be the result of above code ?

(1) i = 2 j = 1
(2) i = 1 j = 2
(3) i = 2 j = 2
(4) The program compilation fails because of line number 6.

Answer:

(1)

Related Tags for SCJP Module-5 Question-3:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.