What is the result of the following program execution?

class Test2 {
    static int N(Integer x) {
        return x;

public class Test {
    static int M(Integer v){
        return v;
    public static void main(String[] args){
        Integer x = M(100);     // 1
        Integer z = N(100);     // 2
        System.out.println(x + " " + z);
In line 1, the method will be found and 100 will be autoboxed to Integer, the method will return an int, hence the object will be autounboxed, but x is an Integer object and 100 will be autoboxed again into Integer.
A compilation error will occur in line number 2 because the method N(int) will not be found.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Sign Up Now
or Subscribe for future quizzes