Answer to Question #174840 in Java | JSP | JSF for Prisy

Question #174840

1.  Identify two instance variables and two methods from the case below.

An application that manipulates Points on a plane is to be designed using Objected Oriented

Design. In this application, Points must have X and Y coordinates, move on the plane as well as display their current values of X and Y. Points can also determine if they are in the zero position (0,0) with a Boolean answer. [8]

 

a. Assume the existence of a Java file myClass.java. Explain how Java uses both a compiler and interpreter to achieve its architecture-neutral characteristic. [5]

b. Using an example, explain the implication of using the keyword void in a method declaration

c. Given an Object-Oriented System that manages student records (name, date of birth,[3]

d. gender etc), use examples to differentiate between Class and Object as used in OOP.[4]


1
Expert's answer
2021-03-23T18:43:15-0400
import java.util.ArrayList;

public class Points {
    private ArrayList<Integer[]> points;

    public Points() {
        points = new ArrayList<>();
    }

    public boolean isZeroPosition(int i) {
        return points.get(i)[0] == 0 && points.get(i)[1] == 0;
    }

    public void addPoint(int x, int y) {
        points.add(new Integer[]{x, y});
    }

    public void movePoint(int i, int dx, int dy) {
        points.get(i)[0] += dx;
        points.get(i)[1] += dy;
    }


    public void display() {
        for (Integer[] point : points) {
            System.out.println("X= " + point[0] + " Y= " + point[1]);
        }

    }
}
  1. The java compiler compiles the code contained in the java file into byte code which is then interpreted by the JVM.
  2. The void keyword indicates that the method does not return any values and the programmer should not process any data after the method has completed.
  3. class is everything that is in curly braces after the signature with the class keyword, while an object is a variable created using the new keyword.

public class Student{

//...

}


Student student = new Student();



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Prisy
24.03.21, 00:50

Wow. Thank you so much for your kind help.

Leave a comment

LATEST TUTORIALS
New on Blog