How to know when two specific object colide

hello I want to know how to trigger something when only two specific objects colide. for example when the ball object hits the wall changes to red color and when it hits the floor it turns blue (just for example). any thoughts?

You should take a look at OnCollisionEnter

Using your specific example (in Javascript):

function OnCollisionEnter( collisionInfo : Collision )
{
   if ( collisionInfo.gameObject.tag == "wall" )
   {
      renderer.material.color = Color.red;
   }
   if ( collisionInfo.gameObject.tag == "floor" )
   {
      renderer.material.color = Color.blue;
   }
}

This script would be attached to your ball, and assumes you have a collider/rigidbody on both objects (and neither are kinematic). You'd also need to create tags for 'wall' and 'floor', and specify it on each object.

Finally, there are plenty of similar questions about OnCollisionEnter. In future, try searching around and having a go on your own first.