Question: Suppose the following method is defined in some class: public int someMethod ( int x ) { return x + z; } Assume that the

Suppose the following method is defined in some class:
public int someMethod(int x)
{
return x + z;
}
Assume that the rest of the surrounding class has been defined correctly, and thatzis the name of a static field variable in that class.
What, if anything, is wrong with this code?
Question 3Answer
a.
A static method is calling a non-static method, which is not allowed.
b.
A non-static method is calling a static method, which is not allowed.
c.
A static method is calling a non-static field (instance) variable, which is not allowed.
d.
A non-static method is calling a static field variable, which is not allowed.
e.
Nothing is visibly wrong with the code (other than uninformative method and variable names)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!