Object o = "hello";
int len = o.length();What is wrong?
- A
o cannot reference a String
- B
Nothing is wrong
- C
Strings have no length method
- Dcheck_circle
Object has no length(); cast o to String first
Explanation
The compile-time type of o is Object, which does not declare length(). Casting ((String) o).length() resolves the call.