
Create a singe wire mesh composed of one edge, connecting the two cubes as desired.
Subdivide it a few times in Edit Mode. Create a new Vertex Group for the tips where you will only include the two end vertex (will be used for pinning later).
Now Object Mode select one of the cubes, then Shift select the cable so that both are selected. With both still selected enter Edit Mode on the cable and select only the corresponding tip vertex.
Hook that vertex to the cube by searching the Space Bar menu for Hook to Selected Object
. Repeat the process for the other cube with its corresponding end vertex.
Now activate a Cloth physics type for the cable, and pick the previously created Vertex Group for pinning.
Add a Skin modifier to give the cable some thickness
Add a Subsurf modifier to the cable mesh at the end of the stack to get a circular section cable and smoother results.

Rearrange your modifier stack if necessary to make sure both hooks are at the top of the list, followed immediately by the physics modifier.
You can now move the cubes and have the cable behave realistically.

You can optionally add a second Subsurf modifier to the rope before skinning to get smoother bending, or alternatively right before the physics modifier for a more detailed simulation. Beware that the second option will considerably affect simulation complexity, and may severely affect performance and calculation time.