Question: A part of the LineSI class from Section 5.6.1 is shown below. Identify necessary and unnecessary use of the keyword this. public class LineSI {

A part of the LineSI class from Section 5.6.1 is shown below. Identify necessary and unnecessary use of the keyword this.

public class LineSI { // data members private static final double DEFAULT_VALUE

public class LineSI { // data members private static final double DEFAULT_VALUE private double slope; private double intercept; // methods public void setSlope (double slope) { this.slope = slope; } public void setIntercept (double intercept) { this.intercept = intercept; } = 0.0; public void set Intercept (double intercept) { this.intercept = intercept; } public void setLine (double slope, double intercept) { // using set Slope and setIntercept methods this.setSlope (this.slope); this.setIntercept (this.intercept); } public void setLine (PointD pt1, PointD pt2) { // using first setLine method this.setLine ((pt2.getY ()-pt1.getY ()) / (pt2.getX ()-pt1.getX () ), ((pt2.getX() *pt1.getY()) (pt1.getX() *pt2.getY()))/(pt2.getX()-pt1.getX()));

Step by Step Solution

3.46 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

In the Java programming language the this keyword is used within an instance method or a constructor to refer to the current objectthe object whose me... View full answer

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 Introduction Java Program Questions!