To query groups in Salesforce, use two objects: Group, which holds every public group, queue and role group, and GroupMember, which holds one row for each member of a group. A SOQL query on Group and GroupMember lets you list public groups and queues, see who is in them, and find every group a user belongs to.
The catch is that GroupMember only returns IDs, and members can be other groups or whole roles, not just users. In this tutorial, I ran every query in a Salesforce Developer Edition org with two test public groups, so you can see the real results, including how to turn IDs into names and how to expand nested groups in Apex.