Knute, I followed your suggestion that ACTIONS ON OBJECTS are put in methods and when done so properly, my program now compiles and executes without error.
class T { int x =1, y=2;
public void prt() {
System.out.println("T class ending: x= " +x+ ", y=" +y); }
}
class S extends T {
int m = 10;
int n = m + x +y;
public void prs() {
System.out.println("S subclass ending: m = " + m + ", n=" + n); }
}
public class A{
public static void main(
String[] arg) {
System.out.println("****Program start");
T t1 = new T();
t1.prt();
S s1 = new S();
System.out.println(s1.m);
System.out.println(s1.n);
s1.prs();
System.out.println("****Program ending");
} }
However, is it true my prt() method MUST be called from the instantiating method, main() here?
Can my prt() method be called FROM WITHIN CLASS T ITSELF, using "this" or other constructs? ie can a class invoke its own method?
Thank you for giving a thorough answer!!