In how many ways $4$ mathematics books, $3$ physics books, $2$ chemistry books and $1$ biology book can be arranged on a shelf so that all books of the same subjects are together.
Consider the $4$ mathematics books as a single book;
the $3$ physics books as a single book;
the $2$ chemistry books as one book.
Then there are $4$ books in all.
$4$ books can be arranged on a shelf in $4! = 4 \times 3 \times 2 \times 1 = 24$ ways
Now, the $4$ mathematics books can be arranged amongst themselves in $4! = 24$ ways
The $3$ physics books can be arranged amongst themselves in $3! = 3 \times 2 \times 1 = 6$ ways
The $2$ chemistry books can be arranged amongst themselves in $2! = 2 \times 1 = 2$ ways
$\therefore \;$ All the given books can be arranged on a shelf so that all books of the same subject are together in $\; 24 \times 24 \times 6 \times 2 = 6912$ ways