Problem

What’s the Output?a. Determine the output of the following code:   public class Point   { ...

What’s the Output?

a. Determine the output of the following code:

   public class Point   {        int x, y;        public Point ()        {             x = y = 0;        }        public Point(int a, int b)        {             x = a;             y = b;        }        public boolean equals(Point p) // tests whether or not two Points are equal        {             return ( p.x == x && p.y == y);        }   }

   public class Example   {        public static void main(String[] args)        {             Point a;             Point b;             a = new Point(3, 4);             b = new Point (3, 4);             System.out.println(a.equals(b));        }   }


b. Determine the output of the following code:

   public class A   {        public void X()        {             System. out. println("Class A; method X");        }        public static void Y()        {             System.out.println("class A; method Y");        }   }

   public class B extends A   {        public void X()        {             System.out.println("class B; method X");        }        public static void Y()        {             System.out.println("class B; method Y");        }   }

   public class MethodCalls   {        public static void main(String[] args)        {             A a = new B();             a.X();             a. Y();             B b = new B();             b. X();             b.Y();        }  }

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 13
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