Questions i to vii relate to the following code a class


Questions (i) to (vii) relate to the following code. A class called Point is defined and the code fragments that are called from main() are given line numbers 1 to 7.
public class Point
{
private int x;
private int y;
public Point(int xIn, yIn)
{
x = xIn ;
y = yIn ; }
public int getX()
{
return x ; }
}
The following code is called from main()
1. Point[] points = new Point[2];
2. Point a = new Point(1, 1);
3. Point b = new Point(2, 0);
4. Point c = new Point(0, 2);
5. points[0] = a;
6. points[1] = b;
7. int value = points[1].getX();
//after run the above code, now we add line
8
8. points[2] = c;
Explain, using a diagram to support each of your answers
(i) What has been created and stored after line 1 is executed?
(ii) What has happened after lines 2 - 4 are executed?
(iii) What has happened after lines 5 and 6 are executed?
(iv) What is stored in the array points before line 7 is executed?
(v) What has happened after line 7 is executed?
(vi) What is stored in value at line 7?
(vii) What happens when we recompile after line 8 is added?

b) Discuss any problem you consider may arise from the above program. Suggest a possible solution to this and explain how it would work.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Questions i to vii relate to the following code a class
Reference No:- TGS01249305

Expected delivery within 24 Hours