Consider the following code, and suppose the main method in …
Consider the following code, and suppose the main method in Sub is executed. public class Super { private String y; public Super () { stut();} public void stut() { if (y == null) {y = “cat”;} else {y = y + y;}} } public class Sub extends Super { private String x; public Sub (String s) { x = s;} @Override public void stut() { x = x + x; } public static void main(String[] args) { Super s = new Sub(“dog”); } } Is this true or false: the stut() method in Super is invoked
Read DetailsConsider the following code, and suppose the main method in…
Consider the following code, and suppose the main method in Sub is executed. public class Super { private String y; public Super () { stut();} public void stut() { if (y == null){ y = “cat”; } else { y = “dog”; } System.out.println(y); }} public class Sub extends Super { private String x; public Sub (String s) { x = s;} @Override public void stut() { x = x + x; System.out.println(x); } public static void main(String[] args) { Super s = new Sub(“dog”); }} What is the output?
Read Details