In the first figure, the vector field is everywhere parallel to the cylinder, so the flux must be zero. In the second figure, although there is nonzero flux locally, the symmetry of the cylinder (and the constancy of the vector field) ensures that the flux in on the left is the same as the flux out on the right, so that the total flux is again zero.
Look before you leap!
Flux is given by \(\displaystyle\int\boldsymbol{\vec F}\cdot d\boldsymbol{\vec A}\), where \(\boldsymbol{\vec A}=\boldsymbol{\hat n}\,dA\). For the sides of the cylinder, \(\boldsymbol{\hat n}=\boldsymbol{\hat r} =\frac1r(x\,\boldsymbol{\hat x}+y\,\boldsymbol{\hat y}\)), so \(\boldsymbol{\vec F}\cdot\boldsymbol{\hat n} =\frac{x^2+y^2}{r}=r=2\), so the flux through the sides is just twice the area, namely \(2\pi rh=2\pi(2)(6)=24\pi\).
For the two caps, \(\boldsymbol{\hat n}=\pm\boldsymbol{\hat z}\), so \(\boldsymbol{\vec F}\cdot\boldsymbol{\hat n}=\pm z=+3\) in both cases, so the flux through the caps is \(3+3\) times the area, namely \(6\pi r^2=24\pi\).
Adding up the pieces, the total flux out of the cylinder is \(48\pi\).
Working in spherical coordinates, the angle between \(\boldsymbol{\hat z}\) and \(\boldsymbol{\hat n}=\boldsymbol{\hat r}\) is clearly the spherical angle \(\theta\) (colatitude). Furthermore, since the vertical projection of \(r\,\boldsymbol{\hat r}\) is \(z\,\boldsymbol{\hat z}\), we also have \(z=r\,\cos\theta\). Thus, \(\boldsymbol{\vec F}\cdot\boldsymbol{\hat n} = z^2\cos\theta = r^2\cos^3\theta\). So \begin{align*} \int\boldsymbol{\vec F}\cdot d\boldsymbol{\vec A} &= \int r^2\cos^3\theta\,dA \\ &= \int r^2\cos^3\theta (r^2\sin\theta\,d\theta\,d\phi) \\ &= 2\pi r^4 \int \cos^3\theta\sin\theta\,d\theta \\ &= -2\pi r^4 \frac{\cos^4\theta}{4} \bigg|_0^{\pi/2} = \frac{625\pi}{2} \end{align*}
Flux is given by \(\displaystyle\int\boldsymbol{\vec F}\cdot d\boldsymbol{\vec A}\), where \(\boldsymbol{\vec A}=\boldsymbol{\hat n}\,dA\). Since \(\boldsymbol{\hat n}\) is given, compute the dot product: \(\boldsymbol{\vec F}\cdot\boldsymbol{\hat n}=5\). Thus, the flux through the square is 5 times the area, namely \(5(2^2)=20\).
The plane lies at a 45-degree angle in the \(xz\)-plane, so along lines with \(y=\hbox{const}\), we have \(dy=0\) and \(dz=dx\), so \(d\boldsymbol{\vec{r}}_1 =dx\,\boldsymbol{\hat{x}}+dx\,\boldsymbol{\hat{z}}\). Along lines in the \(y\) direction, \(x\) and \(z\) are constant, so \(d\boldsymbol{\vec{r}}_2=dy\,\boldsymbol{\hat{y}}\). Therefore, \[d\boldsymbol{\vec{A}} =d\boldsymbol{\vec{r}}_1\times d\boldsymbol{\vec{r}}_2 =dx\,dy\,(\boldsymbol{\hat{x}}+\boldsymbol{\hat{z}})\times \boldsymbol{\hat{y}} =dx\,dy\,(\boldsymbol{\hat{z}}-\boldsymbol{\hat{x}}).\] Since the coefficient of \(\boldsymbol{\hat{z}}\) is positive, we have indeed chosen the correct orientation.
The flux integral now becomes \[\int_R \boldsymbol{\vec{H}}\cdot d\boldsymbol{\vec{A}} = \int_R \bigl((3+2z)-2z\bigr)\,dx\,dy = \int_0^2 \int_0^3 3\,dx\,dy = 18 . \]
This is a straightforward Gauss's Law problem: \begin{align} \oint \vec{E}\cdot \hat{n}\, dA &=\frac{1}{\epsilon_0} Q_{\text{enclosed}}\\ &=\frac{1}{\epsilon_0}\int_0^L \lambda_0 dz\\ &=\frac{1}{\epsilon_0}\lambda_0 L \end{align}
Consider the volume charge density: \begin{equation*} \rho (x,y,z)=c\,\delta (x-3) \end{equation*}
This equation represents a charged plane oriented parallel to the \(y,z\)-plane and located at \(x=3\).
The delta function has dimensions of inverse length, and the volume charge density has dimensions of charge per length cubed, so \(c\) has dimensions of charge per length squared.