Theory:

Line
A line is obtained by extending the line segment infinitely in both directions. It has an infinite number of points. A line is labelled sort of a line segment with a bidirectional arrow over the label.
Line.PNG
 
The above figure shows a line \(AB\) and is represented as \(\overleftrightarrow {AB}\) or \(\overleftrightarrow {BA}\). Sometimes the line is denoted by a letter like \(m\), as showed in the above line.
Example:
The \(100\) metres track is to illustrate the concept of the line. A track may be a line that extends infinitely in both directions without having a fixed starting and ending point.
as.PNG
Ray
A ray is a part of a line. It starts at one point and extends infinitely in the opposite direction. The ray has an infinite number of points.
The starting point that's fixed at one end is termed as a vertex of a ray.
 
output-onlinepngtools (12).png
 
The above figure shows a ray \(AB\) and is represented as \(\overrightarrow{AB}\).
 
Important!
A ray name should start with a vertex and end in another direction.
 
The name of the above ray is \(\overrightarrow{AB}\) not \(\overrightarrow{BA}\).
Example:
We have a battery-operated torch on one end of the road and, light from the torch (called as line segment) is travelling in a straight line towards the other direction. Since we don't know the end of that light, we will say that this line segment from a fixed source is a ray.
 
output-onlinepngtools (14).png