In which of the following case i get output "Hello World" ?
class A{
@Override
public String toString() {
return "Hello World";
}
}
public class B extends A{
public void print(){
//replace code that displays "Hello World"
}
public static void main(String args[]){
new B().print();
}
}
一、System.out.println(new A());
二、System.out.println(new B());
III.System.out.println(this);
1. only I
2. I and III
3. I and II
4. all I,II and III
它的answer is 4
即all I,II and III
i understood about I but why II and III is also right ?
EDIT : Also specify which section of jls provides this specification ?