There is no polymorphism of member variables, and there is a multi-state.

xiaoxiao2021-03-06  42

/ ** * @author 031202 * * TODO To change the template for this generated type comment go to Window - * Preferences - Java - Code Style - Code Templates * / public class Test {public static void main (String [] args) { Base b = new subclass (); system.out.println (bx); system.out.println (b.method ());}}

Class base {INT x = 2;

INT method () {returnix x;}}

Class Subclass Extends Base {INT X = 3;

INTMETHOD () {Return x;}} answer: 23

转载请注明原文地址:https://www.9cbs.com/read-63152.html

New Post(0)