Question 1:
(a) Write the definition of a class called ‘Point' in Java. The class should contain the following:-
(i) Two integer variables x and y declared protected.
(ii)The class Point has a public no-argument constructor to set the coordinates at the Origin (0, 0).
(iii)A second constructor with 2 parameters to set the coordinates of the point at the location defined by the parameters.
(iv)A public method to set the coordinates of the point at the location defined by the global protected variables x and y.
(v) A public get method to return the x-coordinate.
(vi) A public get method to return the y-coordinate.
(vii) A public String method to return the location of the point.
Question 2:
(b) Now write the definition of a class called ‘Circle' which inherits from the class Point.
The class Circle should contain the following:-
(i) A protected variable for the radius of the circle
(ii) A no-argument constructor to set the radius to 0.
(iii) A constructor containing 3 parameters and which calls the superclass constructor with the values and to set the radius.
(iv) A public method to set the radius of the circle.
(v) A public method to return the value of the radius
(vi) A public method to compute the area of the circle
(vii) A String method to return the location of the centre of the circle and its radius.
(c) Write the code for a test class to pass the different values of radius and coordinates and to compute the area of the circle.
(d) Briefly explain what is meant by the term ‘polymorphism' in Java.