[Solved] Why can’t i call a method within a protected method of the same class [duplicate]

Introduction When writing code in an object-oriented language, it is important to understand the concept of access modifiers. Access modifiers are used to control the visibility of class members, such as methods, variables, and constructors. One of the access modifiers is the protected modifier, which allows a class to access its own members, but not … Read more

[Solved] Why can’t i call a method within a protected method of the same class [duplicate]

You are creating local variables of button1, button2 etc inside the onCreate method. This way, the generateQuestion method is unaware of these variables and uses the class variables with the same name (not included in your code, but I imagine you have somewhere declared them probably on top of your activity class) which are not … Read more