40% is 40 grams per 100 ml of solution, which is about 7.1 M. This is a dangerously caustic solution, and it will also become very hot when the pellets are dissolving. Extreme care should be exercised. Wear eye protection, gloves, and protective clothing (such as a lab coat). If you don't really need such a concentrated solution, make a less concentrated one.
Put about 50 ml of water in a 150-ml or 250-ml Pyrex beaker with a magnetic stir bar and start it stirring on a magnetic stirrer. Slowly, add the 40 grams of pellets a few at a time, adjusting the stirring speed to keep the pellets swirling around, but not so fast that the liquid spills out the top or splashes. Once all of the pellets have been added, keep stirring until they have completely dissolved. Set the beaker aside until the solution cools down. Transfer the solution carefully into a graduated cylinder or, preferably, a 100-ml volumetric flask, using a funnel. Be careful not to spill any. Transfer residual liquid in the beaker by adding small amounts of water to it and combining the washes with the larger volume. Add water to the cylinder or flask to bring the volume to 100 ml. Mix the solution thoroughly, then transfer it to a plastic bottle with a screw cap if you want to store it. (You should not store strong bases for long in glass containers because they react with the glass.) Make sure to clean any spills thoroughly and wash down the surface with plenty of water. Wash out the glassware used to prepare the solution very thoroughly with lots of distilled water.
If you mean 40% (w/w) KOH solution (in most cases, it is w/w), you need to add 40 gm of KOH pellets to 60 mL of DI water. Here is the calculation: 40% w/w means m_KOH=40 gm; m_KOH + m_H2O = 100 gm. So, m_H2O=100-40 = 60 gm. Considering the density of water to be 1 gm/mL, 60 gm of water is 60 mL of water.
Note: 40% (w/w) KOH doesn't mean 40 gms of KOH per 100 mL of solution. It should be 100 gm of solution.