Which code fragment can replace the if block?

Given:

Which code fragment can replace the if block?

A. Option A
B. Option B
C. Option C
D. Option D

Download Printable PDF. VALID exam to help you PASS.

5 thoughts on “Which code fragment can replace the if block?

  1. Option D

    String stuff =”TV”;
    String res = null;
    res = stuff.equals(“TV”) ? “Walter” : stuff.equals(“Movie”) ? “White”:”No Result”;
    System.out.println(“Result ::”+res);

    Result ::Walter

  2. only D is written correctly from language syntax rules point of view and will be compiled successfully:
    # javac Test40.java
    # java Test40
    res= Walter

Leave a Reply

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


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