The variableisOKis declared but not initialized, so its value isnull. Theif-elseconditions check for specific values ofisOK(trueorfalse), but since it isnull, none of those conditions are satisfied. The program defaults to theelseblock, assigning4tox. Reference:Apex Developer Guide: Boolean Data Type