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

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes