  Given an i.i.d. sample $X_1,...,X_n$ with common bounded density $f_0$
belonging to a Sobolev space of order $\alpha$ over the real line, estimation
of the quadratic functional $\int_{\mathbb{R}}f_0^2(x) \mathrm{d}x$ is
considered. It is shown that the simplest kernel-based plug-in estimator
\[\frac{2}{n(n-1)h_n}\sum_{1\leq i<j\leq n}K\biggl(\frac{X_i-X_j}{h_n}\biggr)\]
is asymptotically efficient if $\alpha>1/4$ and rate-optimal if $\alpha\le1/4$.
A data-driven rule to choose the bandwidth $h_n$ is then proposed, which does
not depend on prior knowledge of $\alpha$, so that the corresponding estimator
is rate-adaptive for $\alpha \leq1/4$ and asymptotically efficient if
$\alpha>1/4$.
