When I gave my code in the exam class like
\begin{parts}
\part \begin{lstlisting}
echo The date is $date
\end{lstlisting}
\part \begin{lstlisting}
echo The date is $(date)
\end{lstlisting}
\end{parts}
I want is the line starting with echo in (a) and (b) respectively. Instead that only \part displays only (a)

\parbetween\end{lstlisting}and\part. – cgnieder Mar 6 at 8:20