Question: Question 2 (10 marks): Design a class named Point that meets the following requirements: Two data fields w and z for representing a point with

 Question 2 (10 marks): Design a class named Point that meets

Question 2 (10 marks): Design a class named Point that meets the following requirements: Two data fields w and z for representing a point with getter methods. A no-arg constructor that constructs a point for(0,0). A constructor that constructs a point with the specified w and z values. Override the equals method. Point pl is said to be greater than point p2 if pl.w==p2.w and pl.z==p2.z. Implement the Comparable interface and the compare Tomethod. Point pl is said to be greater than point p2 if pl.w>p2.w or if pl.w==p2.w and pl.z>p2.z. Override the toString() method to return a string as (w value, z value). Implement the Cloneable interface and clone method. Complete and run your program using the following code: public class Ques_02 { public static void main(String[] args) { Pointl pl = new Point(3, 4); Pointl p2 = new Point(3.4, 1.4); System.out.println(pl.equals(p2)); System.out.println(pl.equals(pl)); System.out.println(pl.compare To(p2)); System.out.println(p2.compareTo(p1)); Pointl p3 = (Pointl)(p1.clone(); System.out.println(p3.equals(p1)); System.out.println(p3); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!