What will be the result of compilation and running the following code:

import java.util.Formatter;
public class Formating {
    static Formatter formatter = new Formatter();
    public static void main(String[] args) {
        System.out.print(
            formatter.format("%b %b %b",
                new Boolean(null), 
                new Boolean("bool"), 
                8
            )
        );
    }
}
Explanation
%b: Produces either "true" or "false" as returned by Boolean.toString(boolean). If the argument is null, then the result is "false". If the argument is a boolean or Boolean, then the result is the string returned by String.valueOf(). Otherwise, the result is "true". http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html
Java
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback