What is the result of compiling and executing the following class?
public class MyClass { static int w = 1; int t = 5; public static void main(String[] arguments) { MyClass s = new MyClass(); int feet=4, t = 15; System.out.print(feet + t + s.w); } }
D.
The code compiles and runs without issue, so Option A is incorrect.
The variables feet and t are locally scoped and set to 4 and 15, respectively.
Finally, the static variable s.w has a value of 1.
The result is the combined value is 20, making Option D the correct answer.