As the cosine is defined as $cos \theta = \frac x r $ where x is the length of opposite line and r is length of hypotenuse how can $cos \theta$ be calculated for values where we do not know the lengths of sides of triangles. ?
Various calculators compute the $cos(1) = .999$ , so is there an implicit value for lengths of opposite and adjacent sides ?
This picture should solve your doubt:
Say the angle $\widehat{BAC}$ is $\theta$; then $$ \cos\theta=\frac{b}{r}=\frac{b'}{r'} $$ where $b=AB$, $b'=AD$, $r=AC$ and $r'=AE$, because the two triangles $ABC$ and $ADE$ are similar right triangles.
So, while one needs an “implicit value” for the length, it's immaterial which one you choose, because the ratio will be the same.
In the past, in order to avoid decimal numbers, the length of the hypothenuse was taken to be, say, $100\,000$ and the cosine was defined to be the adjacent leg (no ratio). However, this just complicates formulas, so it became common to use an implicit length of $1$ for the hypothenuse, which is the same as taking the ratio.
Thus, saying that $\cos 1^\circ\approx 0.9998$ means that if the hypothenuse is $1$ (meter, foot, yard, centimeter), then the adjacent leg will be approximately $0.9998$ (in meters, feet, yards, centimeters, whatever unit you chose). If the hypothenuse is $2$, you'd get an adjacent leg approximately $1.9996$.