How to define field in parent class and assign value in child to this field so it will be accessible for type Room? I think this int bound = 3; will hide parent variable…
public abstract class Room {public int bound; }
public class DarkRoom extends Room {
bound = 3;
}
Assign the field in the constructor, not in the class declaration: