The problem is: you may have several instances of ObjectA and ObjectB in your scene, thus you must have a reference to the target object to get its script. And what’s a reference? In Unity, any object component is a reference: GameObject, Transform, Collider, Rigidbody etc (but GameObject and Transform are more popular, because any game object has both).
You can drag the object to the reference variable in the Inspector, or you can find the object with Find, FindWithTag etc., or you can get its collider when colliding with it, etc.
Using a reference, your code would become:
public int ScrptAInt = 5;
public Transform objB; // <- drag object B here (objB is the reference)
void Update()
{
ScriptB B = objB.GetComponent< ScriptB>(); // the generic version doesn't need typecasting
B.ScriptBInt = ScriptAInt;
}