What will be the output of the following code?

public class Test {
    int i = 10;
    public int hashCode() {
        return i;
    }
    public static void main(String ... a) {
        System.out.println(String.format(" %1$b  ", new Boolean("fAlSe")) );
        System.out.println(String.format(" %1$H %2$s", new Test(), null ) );
    }
}
Explanation
Constructor Boolean(String) will always return false except when argument equals "true" ignoring case.
%1$H - will call (new Test()).hashCode() and show the result as hexadecimal string.
Java
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback