Stored in the array points before line seven

Assignment Help C/C++ Programming
Reference no: EM13939993

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.

Reference no: EM13939993

Questions Cloud

Compute a predetermined overhead rate for the plant : Compute a predetermined overhead rate the plant as a whole based on machine hours. Compute predetermined overhead rates for each department using machine hours.
Reads an input record and prints the name : Reads an input record and prints the name if the current total is less than the limit.
Describe four features of a map data structure : Describe the problems that may be encountered when computing the hash codes for adding objects into a simple array implementation of a hash table.
Evaluate approaches to self-managed learning : Evaluate approaches to self-managed learning- you will need to formulate and research ideas on why it is important to manage your own learning. Use the information that you have been given in class to set yourself some short term goals on your lea..
Stored in the array points before line seven : 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.
How has hiv affected the population distribution in africa : How has HIV/AIDS affected the population distribution in Africa (especially Southern Africa)? What social processes have driven such high rates of the epidemic and how might the spread of HIV/AIDS be contained in this area of the world
Calculate a plantwide rate for xanning company : Calculate a plantwide rate for Xanning Company based on machine hours. What is the bid price of each job using this rate?
Highest population densities in canada : Fertile soil laid down at the conclusion of the Pleistocene Ice Age by wind is called: and The highest population densities in Canada are found in
Difference between aggregation and inheritance : A class called Employee has attributes for the name of the person and his/her salary, together with methods for accessing the attributes and methods for setting the attributes. A class SalesPerson is inherited from class Employee (described above)..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Reduce the numerator and denominator

Write the function  in C ++ to reduce the numerator and denominator in the Rat class to lowest terms.

  Display all entries in order by ascending number of atoms

We have been given a file of chemical formulae, specifically hydrocarbons that consist of only hydrogen and carbon atoms.

  rewrite that statement in a more readable style.

Give an example statement in C, C++, or Java that is particularly unreadable. Rewrite that statement in a more readable style.

  Use the lengthof the side as a member variable of the class

write a class including four member functions to compute the areas of an equilateral triangle ,square,hexagon and octagon respectively .Use the lengthof the side as a member variable of the class.

  Make an explicit statement of the invariant of the set class

Prepare a new container class called ser, which is similar to a bag, except that a set can contain only one copy of any given item, you'll need to change the interface a bit.

  What mechanism allows the overloaded subscript operator

What mechanism allows the overloaded subscript operator [] to be used on the left side of an assignment statement, like this: v[2] = 22?

  Write a c++ program to check a number is even or odd

Write a C++ program to check whether a number entered by user is even or odd.

  Write an iterative function power

Write an iterative function power1 to compute xn for n >= 0 and write a recursive function power2 to compute xn by using the following recursive formulation

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Digital filtering

Write a main code that reads filter coefficient data from the file filter.txt and creates a filter, reads an input float_seq from the file input.txt, filters the input float_seq using the filterand then writes the output float_seq to the file, output..

  How do you make a row with different string names

How do you make a row with different string names and put a certain amount of space between each one?

  Consider the subsequent selection statement where x is an

consider the subsequent selection statement where x is an integer test score between 0 and 100.input xif 0 lt x and x

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd