Private methods in Inheritance

后端 未结 9 1756
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 04:19

Here\'s an interesting code snippet:

public class Superclass {

    public static void main (String[] args){
        Superclass obj = new Subclass();
                


        
9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 04:39

    You answered it yourself. As the private methods are not inherited, a superclass reference calls its own private method.

提交回复
热议问题