Option B
The longest diagonal would be from one corner vertex to the diagonally opposite corner vertex.
$\text{Length of diagonal of a side} = \sqrt{a^2 + a^2} = \sqrt{2}a$
The diagonal of a square face of cube, a side of the cube and the longest diagonal will form a right angled triangle with longest diagonal as the hypotenuse.
$\therefore \text{Length of the longest diagonal} = \sqrt{a^2 + \left(\sqrt{2}a\right)^2} = \sqrt{3}a$
$\cos\theta = \frac{\text{Base}}{\text{Hypotenues}} = \frac{a}{\sqrt{3}a} = \frac{1}{\sqrt{3}}$