Ask Question

Two methods defined within a class are shown below. What can be said about the variable x used in both methods?

public int getSum (int y) {

return this. x + y; }

public int getMult (int y) {

return this. x * y; }

+5
Answers (1)
  1. 30 March, 04:57
    0
    Hi! Well, the variable 'x' is preceded by 'this.'. I can't say for sure what language this is, but it's probably Java or a C language, right? Then the 'this' refers to the instance of the class.

    So 'x' is an instance variable. That means it's a variable that belongs to an instantiated object.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Two methods defined within a class are shown below. What can be said about the variable x used in both methods? public int getSum (int y) { ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers