What will be the result of the following program execution?

import java.util.*;
public class TestFormatter {        
    public static void main(String... args){
        Integer I1 = 0;
        Integer I2 = -1;
        Integer I3 = 1;
        Formatter f = new Formatter();
        f.format("%1$b ", I1.toString())
         .format("%1$b ", I2.toString())
         .format("%1$b ", I3.toString());
$b sequence is processed as follows:
- if a boolean value is passed, then its string representation will be a result ("true" or "false");
- If null is passed, then "false" will be a result;
- In all other cases (and in this example in particular) "true" will be a result
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback