Question: Given the code: public class MyClass { private int z; public void setZ ( int z ) { this.z = z; } private int getZ

Given the code: public class MyClass { private int z; public void setZ(int z){ this.z = z; } private int getZ(){ return z; }} Where is the error?
Question 4 options:
No error
The variable z should be public
The method getZ should be public
The class MyClass should be private

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!