大家讲道理2017-04-18 10:53:31
You called the test() method in the constructor of the parent class, so that test() will be called when new is created. However, you did not call the test2() method, and there will definitely be no output. This is the basics of Java. in principle. You can write like this and there will be output.
public Base{
test();
test2();
}
PHPz2017-04-18 10:53:31
It would be better to directly copy the code for your question instead of taking screenshots.
Because your code does not call the test2 method from beginning to end. It only calls the test method on line 5. You can write it on line 6test2();
高洛峰2017-04-18 10:53:31
You have not called the test2 method of the parent class, so there will be no output.
大家讲道理2017-04-18 10:53:31
test2() is not called in subclasses and categories, this really cannot be output