Originally Posted by
CandorZ
I know that by default member's are private so I should not be able to access the variables without creating an member function that is public.
no, the default access means the the element is visible/accessible inside the same package. so, because the class room is in the same package like the main, also the variable x and z are visible. to be precise, the visibility of default is
from the same class: yes
from any class in the same package: yes
from a subclass in the same package: yes
from a subclass outside the same package: no
from any non-subclass class outside the package: no