Problem

Fix the ErrorsExamine the classes and answer the following questions.a. Find the two Syste...

Fix the Errors

Examine the classes and answer the following questions.

a. Find the two System.out.println() statements that generate compilation errors.

What is (are) the error(s)?


b. If these two lines are deleted, the code compiles. What do the other

 System.out.println() statements display?   public class X   {    private int x;    protected int y;    public X()    {      x = 0;      y = 0;    }    private int helper(int x)    {      return x * x;    }    public int access()    {      return (helper(x));    }   }

   public class Y extends X   {    int x;    public Y()    {      super(); x = 2;    }

    public static void main(String[] args)    {      X temp = new X();      Y tempo = new Y();      System.out. println (temp. access());      System.out. println (tempo. access());      System.out.println(tempo.x);      System.out. println (temp.x);      temp = tempo;      System.out. println (temp. access());      System.out. println (tempo. access());      System.out.println(tempo.x);      System.out. println (temp.x);    }   }

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 12
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT