$AB$ and $CD$ are two parallel line segments. What is the probability of $x$-coordinate of a point in $AB$ greater than a point from $CD$? If I pick 2 points randomly one each from $AB$ and $CD$ respectively, what’s the probability that $x$-coordinate of 1st point is greater than second point. $AB$ and $CD$ are parallel to $x$-axis and could be of different lengths.
For example, consider the cases shown :

I understand by intuition that it has to do with overlaps/ partition lengths. I also performed a numerical calculation in matlab by randomly generating points and counting cases. But,Is there a closed form analytical solution to do case 4?
Question 2 :
Say, If I have several cases for which I find the probability for each case as stated above. Now How do I combine them into a single value of probability ?
 A: Let $X$ be coordinate for point chosen from $CD$
Let $Y$ be coordinate for point chosen from $AB$
Also let $a,b$ and $c,d$ be the x-coordinates of the end points for line segments $AB$ and $CD$ respectively. For simplicity, let's assume that segment $AB$ is always to the the right of $CD$ as in your "case 2". It doesn't change much but makes it simpler since we don't have to consider two separate cases.
We want to find $P(Y > X)$
This is tricky since both $X$ and $Y$ are random. However, suppose we know in advance that $X = x$ then the conditional probability is clearly just the ratio of segment $AB$ that is greater than $x$.
$$P(Y > X|X=x) = P(Y > x) = \frac{b - max(a,x)}{b-a}$$
This is just the length of $AB$ greater than $x$ divided by the length of $AB$.
Now that we have the conditional probability I believe we can find the unconditional probability using the fact that:
$$P(Y > X) = \int_x P(Y > X|X=x).f_X(x)dx$$
(Note: The above is by memory, you might want to double check this. Search up "law of total probability")
Where $f_X(x)$ is the pdf of random variable $X$. Since $X$ is chosen randomly from the segment $CD$, it follows $X$ is just a uniform($c,d$) random variable, which means it has pdf given by:
$$f_X(x) = \frac{1}{d-c}$$
For $c \leq x \leq d$ and $0$ elsewhere.
Hence
$$P(Y>X) = \int_c^d \frac{b - max(a,x)}{b-a} \times \frac{1}{d-c}dx$$
$$=\frac{1}{(d-c)(b-a)} \int_c^d (b - max(a,x))dx$$
$$=\frac{1}{(d-c)(b-a)}(\int_c^d b dx - \int_c^d max(a,x)dx) ( Note 1)$$
$$=\frac{1}{(d-c)(b-a)}(b(d-c) - (a(a-c)  + [x^2/2]_a^d) ( Note 2)$$
$$=\frac{1}{(d-c)(b-a)}(b(d-c) - (a(a-c)  + d^2/2-a^2/2))$$
So that's my attempt, and a lot of that last working follows from thinking how the lines are relative to each other, so that the integrals can be rewritten as products of length. Given this was all in my head it's definitely possible I've made a mistake somewhere so you might want to go through it yourself. Assuming it's correct, I'm sure it can be simplified with some algebra.

A quick explanation for how I got from (Note 1) to (Note 2).
We have two parts of this integral. The first part when $x < a$ and the other than $x \geq a$.
For the first part, $max(x,a)=a$ for all $x$, hence the integral is just the product of $a$ and the interval we integrate over, giving us a(a-c).
For the rest of the interval, from $a$ to $d$ we are integrating $max(a,x)=x$ and hence the 
solution is :$$\int_a^d x dx = [x^2/2]_a^d = d^2/2-a^2/2$$
