What will be printed out to console?

public class Z {
    public void print( Object o ) {
        System.out.println( "Object" );
    }

    public void print( String str ) {
        System.out.println( "String" );
    }

    public void print( Integer i ) {
        System.out.println( "Integer" );
    }
  
    public static void main(String[] args) {
        Z z = new Z();
        z.print( null );
    }
}
Explanation
If class contains several overloaded methods and their arguments are not in the same hierarchy, then parameter type should by explicitly specified during the method call.

Follow CodeGalaxy

Mobile Beta

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