I am new to chess. Please answer this for me:
Is it possible to castle with checkmate?
I can think of two questions you might be meaning to ask, given the wording of your question. Maybe neither of these is what you're after, but just in case:
1. Is it possible to castle out of check or even checkmate? Here the answer is no. If your king is in check, then castling is not a legal move.
2. Is it possible to castle while checkmating your opponent? Here the answer is yes, it is possible, though it does not happen often. For instance, the game Ed.Lasker-Thomas (1912), with its famous queen sacrifice and king hunt, could have finished with a castling mate:
[fen ""] 1. d4 e6 2. Nf3 f5 3. Nc3 Nf6 4. Bg5 Be7 5. Bxf6 Bxf6 6. e4 fxe4 7. Nxe4 b6 8. Ne5 O-O 9. Bd3 Bb7 10. Qh5 Qe7 11. Qxh7+ Kxh7 12. Nxf6+ Kh6 13. Neg4+ Kg5 14. h4+ Kf4 15. g3+ Kf3 16. Be2+ Kg2 17. Rh2+ Kg1 18. Kd2# (18.O-O-O#)1-0
No-if check mate for your king. Yes- if check mate for opponent's king
If you I asking whether it is legal to castle out of checkmate if it is the only option then no the same rules apply as with check although I can't really think of many instances where you would be able to castle to prevent checkmate...