  We derive stellar population parameters for a representative sample of
ultracompact dwarfs (UCDs) and a large sample of massive globular clusters
(GCs) with stellar masses $\gtrsim$ 10$^{6}$ $M_{\odot}$ in the central galaxy
M87 of the Virgo galaxy cluster, based on model fitting to the Lick-index
measurements from both the literature and new observations. After necessary
spectral stacking of the relatively faint objects in our initial sample of 40
UCDs and 118 GCs, we obtain 30 sets of Lick-index measurements for UCDs and 80
for GCs. The M87 UCDs have ages $\gtrsim$ 8 Gyr and [$\alpha$/Fe] $\simeq$ 0.4
dex, in agreement with previous studies based on smaller samples. The
literature UCDs, located in lower-density environments than M87, extend to
younger ages and smaller [$\alpha$/Fe] (at given metallicities) than M87 UCDs,
resembling the environmental dependence of the Virgo dE nuclei. The UCDs
exhibit a positive mass-metallicity relation (MZR), which flattens and connects
compact ellipticals at stellar masses $\gtrsim$ 10$^{8}$ $M_{\odot}$. The Virgo
dE nuclei largely follow the average MZR of UCDs, whereas most of the M87 GCs
are offset towards higher metallicities for given stellar masses. The
difference between the mass-metallicity distributions of UCDs and GCs may be
qualitatively understood as a result of their different physical sizes at birth
in a self-enrichment scenario or of galactic nuclear cluster star formation
efficiency being relatively low in a tidal stripping scenario for UCD
formation. The existing observations provide the necessary but not sufficient
evidence for tidally stripped dE nuclei being the dominant contributors to the
M87 UCDs.
