Share on Google+Share on Google+

SCJP Module-7 Question-5

Advertisement
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)

Advertisements

Posted on: July 13, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.