Hypothetically speaking, how could adding a protected variable in a superclass create an error in Java? -
just fun, i'm trying think of scenario in protected variable can cause compilation error. lets had class fruit , class apple inherits fruit.
and go ahead , add protected variable x in fruit, causing program no longer compile. happen if how, causing error?
x
inherited apple
without problems. able use inside either fruit
or apple
. might decide override and/or implement setter and/or getter.
Comments
Post a Comment