How private variable track a GameObj?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SceneController : MonoBehaviour {

	[SerializeField] private GameObject enemyPrefab;
	private GameObject _enemy;

	void Update () {
		if (_enemy == null) {
			_enemy = Instantiate (enemyPrefab) as GameObject;
			_enemy.transform.position = new Vector3 (0,1,0);
			float angle = Random.Range (0, 360);
			_enemy.transform.Rotate (0, angle, 0);
		}
	}
}

It’s a code from a book Unity in Action. This code instantiate enemy prefab every time I destroy previous one. One thing I can’t undestand how this line of code"private GameObject _enemy;" keeps track on GameObj that I just Instantiated. So I have a couple of questions.

  1. Is it working because I have just one prefab instantiated in the scene?
  2. How it actualy keeps track on instantiated gameObject without any assingment?
  3. What can you reccomend to read along with Unity in Action to learn C# better, it’s obvious I have no exp in programming languages before. I currently just google every question I have, so it’s hard to make a strong consistant foundation for C# knowledge.

Thanks for the answers!

public class SceneController : MonoBehaviour
{
[SerializeField] private GameObject enemyPrefab;

     // Declare a reference to a gameobject, the instantiated enemy
     private GameObject _enemy;
 
     void Update ()
     {
         // Check if the enemy is null, meaning it has been destroyed, or not yet instantiated
         if (_enemy == null)
         {
             // Instantiate a new enemy from the prefab
             // **and store the reference of the instantiated gameobject into the enemy variable**
             _enemy = Instantiate (enemyPrefab) as GameObject;

             // Set position and rotation of instantiated enemy
             _enemy.transform.position = new Vector3 (0,1,0);
             float angle = Random.Range (0, 360);
             _enemy.transform.Rotate (0, angle, 0);
         }
     }
 }
  1. The condition if (_enemy == null) checks if the last instantiated enemy has been destroyed before instantiating a new one. So you will always have only one enemy in your scene.
  2. There is an assignment : _enemy = Instantiate (enemyPrefab) as GameObject;
  3. You should follow the Unity tutorials on the official website, and try the sample projects.