SCJP Module-7 Question-6

The program given below will test your understanding about the Integer and int data types in Java programming language and helps you for preparation of SCJP exam.

 
 

Share on Google+Share on Google+

SCJP Module-7 Question-6

Ads

The program given below will test your understanding about the Integer and int data types in Java programming language and helps you for preparation of SCJP exam.

Given a sample code:

1    public class Test {
2    public static void main(String[] args) {
3    int i = 1;
4    method(i);
5    }
6    static void method(int i){
7    System.out.println("Primitive");
8    }
9    static void method(Integer i){
10  System.out.println("Wrapper");
}}

What will be the result of above code ?

(1) Primitive
(2) Wrapper
(3) Compile time error at line no 6.
(4) Compile time error at line no 9.

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