Problem 1
A = 5! = 5*4*3*2*1 = 120 ways to arrange the math books
B = 4! = 4*3*2*1 = 24 ways to arrange the French books
C = 2! = 2*1 = 2 ways to arrange the biology books
D = 3! = 3*2*1 = 6 ways to arrange the three blocks of books, each block a different subject
E = A*B*C*D = 120*24*2*6 = 34560 different ways to arrange the books such that the subjects stick together
-------------
========================================
Problem 2
Group all the math books to form one "book". This is the same as taking out the 5 math books and replacing it with one single math book. This single math book acts as a placeholder for all of the five books together as one block.
We have
1 math "book"
4 French books
2 biology books
So there are 1+4+2 = 7 "books" total and
7! = 7*6*5*4*3*2*1 = 5040 different ways to arrange those "books"
Within the math block of books, there are 5! = 120 ways to arrange things.
So overall we have 120*5040 = 604800
-------------