SCJP Module-7 Question-5


 

SCJP Module-7 Question-5

This sample program will test your understanding about the Integer class and int data types in Java.

This sample program will test your understanding about the Integer class and int data types in Java.

Given a sample code:

1    public class Test2 {
2    public static void main(String[] args) {
3    int i = 1;
4    Integer I = new Integer(i);
5    method(i);
6    method(I);
7    }

8    static void method(Integer I) {
9    System.out.print(" Wrapper");
10   }

11    static void method(int i) {
12    System.out.print(" Primitive");
}}

What will be the result of above code ?

(1) Primitive Wrapper
(2) Wrapper
(3) Primitive
(4) Wrapper  Primitive

Answer:

(1)

Ads