It's correct, if the each rod is of uniform density. In general the density could be a function of position of the element of each rod, or of any other bizarre function that makes the problem unsolvable unless we have more information about it to do the integral.

Assuming uniform density, your solution is correct, but let me propose another method:

Knowing that the moment inertia at the centre of a uniform rod is one-twelfth of the mass times the square of length of the rod, I would rather use parallel axis theorem :

https://en.wikipedia.org/wiki/Parallel_axis_theorem and get the moment of inertia of each rods separately at the pivot point, and add them together to get your result. This way I do not need to calculate a single integral.

My solution is acceptable if the problem acknowledges the value of the moment of inertia of a uniform rod at its centre of mass, and therefore allows us to quote it.