Q: What would be the output of the following program ?
public class OverridingTest {
//~ Methods --------------------------------------------------------------------------------------------------------
public static void abc(Object str) {
System.out.println("Object");
}
public static void abc(String str) {
System.out.println("String");
}
public static void main(String[] args) {
// Example of Static polymorphism
abc(null);
abc((Object) null);
String[] str = { null, null, null, null };
for (String st : str) {
abc(st);
}
}
}
Ans : String
Reason : http://www.javafaq.nu/java-article383.html
No comments:
Post a Comment