|
|
350 Mock Questions on SCJP 1.5 - JUST Rs.250 or 7 USD
Send us mail to sales@javabeat.net
more details
|
|
SCJP 5.0 Objective - 3(10 Questions)
1) What will be the output of the following program?
package scjp5_0.chap03;
public class Ques01 {
public static void main(String[] args) {
test1(1, 1.00f, '1');
test1(new Integer(1), new Float(1.00), new Character('1'));
}
static void test1(int a, float b, char c){
System.out.println("Primitive types");
}
static void test1(Integer a, Float b, Character c){
System.out.println("Reference types");
}
}
- The program will result in compilation errors telling that the definition of method test1 is duplicated.
- The program will output 'Primitive types Reference types'.
- The program will output 'Reference types Primitive types'.
- The program will output 'Reference types Reference types'.
Answer
1) b.
Option b is correct. The method test1() will be considered as an overloaded function by the compiler, so the first call (with primitive values) to the method test1() will match the first definition of the test1() method and the second call (with reference values) to the method test2() will match the second overloaded form.
|
|
350 Mock Questions on SCJP 1.5 - JUST Rs.250 or 7 USD
Send us mail to sales@javabeat.net
more details
|
|