java - Is it me or is there a typo in this courseware entry? -


i took online mit courseware discussion (pdf warning):

public class human {   private string name;   ...   public human(string name) {   this.name = name;  }  public string getname() {    return string;   } }  public class student extends human {   private string username;  public student(string name, string username) {   super(name);   this.username = username;  }  public string getname() {   return username;  }  public string getrealname() {    return super.getname();  } } ... public class world {  ...    void somemethod() {     student alice = new student("alice", "abc");     system.out.println(alice.getrealname()); // gets printed? 

why getrealname return anything. know returns alice because constructor called super(name) question about:

return string; 

why doesn't getname in human class have be

return name; 

it should be. it's typo. code have pasted not compile.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -