Which of the method calls and field accesses (shown in underlined bold) in UseSample.java and Sample.java are legal in Java?
public class UseSample { public static void main(String [] args) { Sample s1 = new Sample(1, 2); Sample s2 = new Sample(3, 4); Sample.ourData = Sample.method1(s2) * s2.method3(s1); s1.myData = this.ourData + counter; s2.myInfo = s1.method2(s1) * s2.ourData; Sample.counter += Sample.method4(s1) + 7; } }
public class Sample { public int myData; public static int ourData = 4; private int myInfo; private static int counter = 0; public Sample(int x, int y) { myData = x; myInfo = y; counter++; } public int method1(Sample input) { return input.myInfo + counter * myData - method3(input); } public static int method2(Sample input) { return input.myInfo - Sample.counter + method4(input); } private int method3(Sample input) { return myData - ourData * input.method1(this); } private static int method4(Sample input) { return input.method3(input) + myData; } public static void main(String [] args) { Sample s1 = new Sample(1, 2); Sample s2 = new Sample(3, 4); Sample.ourData = Sample.method1(s2) * s2.method3(s1); s1.myData = this.ourData + counter; s2.myInfo = s1.method2(s1) * s2.ourData; Sample.counter += Sample.method4(s1) + 7; } }