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
Post a Comment