Share on Google+Share on Google+

SCJP Module-5 Question-10

Advertisement
The program given below tests your understanding and logic of for loop in Java and for preparation for SCJP examination.

Given a sample code:

1    public class Test{
2    public static void main(String args[]) throws Exception{
3    for (int i = 5;i < 8;i++){
4    for (int j = 5;j < 8;){
5    System.out.print(i);
6    System.out.print(j+" ");
7    break;
}}
}}

What will be the result of above code ?

(1) Compilation fails at line number 4.
(2) 55 65 75
(3) 5 6 6
(4) 55 66 77

Answer:

(2)

Advertisements

Posted on: July 12, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.