Angell Bulin

Greenhorn
+ Follow
since Feb 26, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Angell Bulin

Marilyn
tester.test( new Object() );
tester.test( tester );
tester.test( new SubTester() );
tester.test( "" );
all these four call pass the explicit object as a parameter, but if you pass null to test(), which method will be used ?
Valentin

if you compile and run these code, could you tell me the result :roll:
why the program1 have compile error, but program2 can compiled?
i think "null" is a object, is wrong?

//------program 1
public class Tester {
void test(Object s) { System.out.println("Object"); }
void test(SubTester s) { System.out.println ("SubTester"); }
void test(String s) { System.out.println ("String version"); }
public static void main (String args[]) {
Tester c = new Tester ();
}
}
class SubTester extends Tester{ }

//------program 2
public class Tester {
void test(Object s) { System.out.println("Object"); }
void test(Tester s) { System.out.println ("Tester"); }
void test(SubTester s) { System.out.println ("SubTester"); }
public static void main (String args[]) {
Tester c = new Tester ();
}
}
class SubTester extends Tester{ }