父类抽象类中的变量是否由子类继承?

时间:2014-08-29 03:16:22

标签: java abstract-class

那么,子类的每个实例,即扩展Tetrimino的J_Tetrimino类都会得到自己的int [] [] UP和String方向吗?

public abstract class Tetrimino {

// [row][col]

/*The size of the area a tetrimino needs*/
protected final int TETRIMINO_SPACE_SIZE = 3;

/*The upwards and initial orientation of the J tetrimino*/
protected int[][] UP;

/*The left and second orientation of the J tetrimino*/
protected int[][] LEFT;

/*The down and third orientation of the J tetrimino*/
protected int[][] DOWN;

/*The right and fourth orientation of the J tetrimino*/
protected int[][] RIGHT;

protected String orientation = "UP";

public String getCurrentOrientation() {
    return orientation;
}

1 个答案:

答案 0 :(得分:2)

是。您发布的抽象类的具体实现的每个实例都将获得其实例。自己的那些领域的实例。它们都不是static,它们会使它们共享。此外,所有这些都是protected,因此它们将在子类中可见(除非它们被遮蔽)。