I see several other answers have arrived while I was writing this, but I’m explaining hypergeometrics in general, rather than the special case “0 choice” answers the other posters have given you, so I’ll do it anyway.
I’m going to use nCk as a notation for "combination of n things taken k at a time. The more normal notation is the two numbers one over top of each other in parentheses, but that’s cumbersome for text-based discussions.
nCk = n! / (k! * (n-k)!)
We can arrive at that by realizing that n! / (n-k)! counts the ORDERED arrangement of the objects: n choices for the first slot, (n-1) for the second, etc, down to n-k. Since we want the combinations without regard to order, we divide by k! since each unordered combination will show up in the ordered list in each of k! orders.
Now, let’s say we choose to split our n up into two categories, like questions you chose to study and questions you didn’t. Let’s designate the number of items in the “special” category as m. Then, the number of combinations representing exactly p of the “special” ones is the number of ways of choosing p from the m special items times the number of ways of choosing k - p from the remaining n - m items: mCp * (n-m)C(k-p).
So, that, divided by nCk will be the probability of getting exactly p of the m “special” items:
= mCp * (n-m)C(k-p) / nCk
In fact, this is called a “hypergeometric” distribution, and you should learn about it in a math class sometime.
Now, apply to your problem. There are 7C4 = 35 combinations which could appear on the test. If you study 3 of them, we have 3 “special” ones, and you are screwed if none of them turn up. The probability of that is
3C0 * 4C4 / 7C4 = 1/35
If you study 2 of them:
2C0 * 5C4 / 7C4 = 5/35
If you study 1 of them:
1C0 * 6C4 / 7C4 = 15/35
Now go study your damned history!