You can use Metadata APIMetadata API to get this information. In AccountSettings there is a field enableAccountTeams
which Indicates whether account teams are enabled (true) or not (false).
You can refer the Metadata API Developer Guide which provides information on how to use Java Code to access Metadata API.
You can get this info using SOQL through Tooling API. Refer to the Tooling API Developer Guide for more details.
Select id, IsAccountTeamsEnabled From AccountSettings