It cannot be done solely in apex, but using visualforce you can use actionsupport for hover and call some apex method and show details. I hope you will get the idea from this small decription.
public with sharing class PopupWindow {
public List<course__c> getCourses() {
List<course__c> courselist = new List<course__c>();
courselist = [Select Id, Name,course_fee__c,Duration__c from course__c LIMIT 5];
return courselist;
}
}
Please check the below sample code.
Visualforce page
Controller
Hope this helps you!
Best Regards,
Jyothsna