What is the result?

Given the code fragment:

What is the result?
A. A B C Work done
B. A B C D Work done
C. A Work done
D. Compilation fails

Download Printable PDF. VALID exam to help you PASS.

5 thoughts on “What is the result?

  1. C
    public static void main(String[] args) {
    String [] strArray = {“A”,”B”,”C”,”D”};
    for(int i=0;i<strArray.length;i++){
    System.out.print(strArray[i]+" ");
    System.out.println("Work done");
    break; //because of break print only A and Work done

  2. Answer C:

    It will print “A” then it will jump the “Work done” because the condition is not met, and then it will break.

Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.