Quiz · Inheritance and polymorphism · lesson 6 of 10
Quiz — overloading by the declared type
What does the program print?
public class Main {
static void g(Object o) { System.out.print("Object"); }
static void g(String s) { System.out.print("String"); }
public static void main(String[] args) {
Object x = "hi";
g(x);
g("hi");
}
}