C# NullReferenceException: Object reference not set to an instance of an object

how to avoid this error in the C# code like this example bellow:

GameboardBehavior.cs:

public class GameboardBehavior : MonoBehaviour {

   private GameObject Obj_A;
   private GameObject Obj_B;

   void Start () {
	  Obj_A = Instantiate (MyPrefab, new Vector3 (10, 10, 0), TilePrefab.transform.rotation) as GameObject;
      Obj_B = Instantiate (MyPrefab, new Vector3 (20, 20, 0), TilePrefab.transform.rotation) as GameObject;
   }

   void test(){
       Debug.Log(Obj_A.transform.localScale.x); // Here it throws an error "object reference not set to an instance of an object"
   }
}

and the second class that attached to each prefab:

Prefab.cs:

public class Prefab : GameboardBehavior {
    ...

    void OnMouseDown (){
	    test ();
    }
}

So i want to access Obj_A parameter fields when clicking on Obj_B. I have the similar code that does a lot more, but this is just an example situation when i getting this error.

MyPrefab - Looks like you haven’t declared that anywhere.

TilePrefab - Also not declared.

You need to get these values from somewhere, you can’t just call them without an instance unless they are static classes.