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 someMethodint 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 Answer
a
A static method is calling a nonstatic method, which is not allowed.
b
A nonstatic method is calling a static method, which is not allowed.
c
A static method is calling a nonstatic field instance variable, which is not allowed.
d
A nonstatic 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
