Number of maths book = 4
Number of physics books = 3
Number of chemistry books = 2
Number of biology books = 1
Since we want books of the same subjects together, we have to treat all maths books as 1 unit, all physics books as 1 unit, all chemistry books as 1 unit and all biology books as 1 unit. Now total number of units = 4
They can be arranged in 4! ways. After this arrangement.
4 maths book can be arranged in 4! ways
3 physics book can be arranged in 3! ways
2 chemistry book can be arranged in 2! ways and 1 biology book can be arranged in 1! way
∴ Total Number of arrangements 4! 4! 3! 2! = 6912