What is the best way to stay motivated and energetic when studying a subject that you are not very fond of?

Keep your eyes on the prize. You need to finish that class with a decent grade so that you can get on with the next thing.

Find a “study buddy” that you can have some fun with while studying. Just remember that you both need to stay focused most of the time.

Make a plan and stick to it. Also reward yourself after accomplishing a certain goal or after studying for 50 minutes.