Say two random variables, $X$ and $Y$, are such that $X$ ~ $U(0,a)$ and $Y$ ~ $U(0,a)$.
What will the pdf be for $Z$, where $Z=X-Y$?
Say two random variables, $X$ and $Y$, are such that $X$ ~ $U(0,a)$ and $Y$ ~ $U(0,a)$.
What will the pdf be for $Z$, where $Z=X-Y$?
On
We need to assume something about the relationship between $X$ and $Y$. For example, if $X=Y$, then $X-Y$ is identically $0$. We will assume what we are expected to assume but should have been mentioned, that $X$ and $Y$ are independent.
We will first find the cumulative distribution function $F(z)$ of $Z$, that is, the probability that $Z\le z$. First deal with the easy cases. If $z\lt -a$, then $F(z)=0$. If $z\gt a$, then $F(z)=1$. It remains to deal with the harder part, when $-a\le z\le a$.
Draw the square with corners $(0,0)$, $(0,a)$, $(a,a)$, and $(0,a)$. For a fixed value of $z$, draw the line $x-y=z$. We want the probability that we end up in the part of the square that has $x-y\le z$, that is, $y\ge x-z$. So we want to be above the line $y=x-z$. The answer looks different depending on whether $z$ is negative or positive. We deal with negative $z$, and leave it to you to deal with positive $z$.
When $z$ is negative, the part of the square where $y\ge z$ is an isosceles right triangle with side $a+z$. This triangle has area $\frac{(a+z)^2}{2}$. The probability we land in that triangle is the area divided by the total area of the square. Thus if $-a\le z\le 0$ then $$F(z)=\frac{(a+z)^2}{2a^2}.$$ For the density function, we will differentiate.
Now it's your turn: deal with $0\lt z\le a$.
Alternately, if you want to integrate, for $-a\le z\le 0$, we have $$F(z)=\int_{x=0}^{a+z}\int_{y=x-z}^a\frac{1}{a^2}\,dy\,dx.$$ To find the limits of integration, it is useful to draw the same picture as the one that gives us the geometric solution.
Here is how I would start:
$$P(Z \le z) = P(X-Y \le z) = \int_0^a P(X \le z+y) f(y) dy$$