dimanche 24 novembre 2019

How is this code going to be run - private variable

So i was giving a coding home interview thing. But i am confused on how theyre gonna run the code. the template is like this:

 public class ABC{
        private int var1;
        public int method(){
               //some operation on private var1 
               return ans;
        }
 }

I am confused because i am not sure how they will set var1... if they are going to be doing loads of test cases they will need to change var1 a lot of times, but its private... should i create a setter method to set var1? but then whats the point of private.

I could just keep changing var1 in the class but i dont think theyre going to run the code like that.

I would ask the company itself but theyre going to take too long..

Aucun commentaire:

Enregistrer un commentaire