“For most of these kids, the opportunities to swim are very limited,” said Mr. Sullivan, who teaches and coaches swimming at Grover Cleveland. “Most are from lower-income and working-class backgrounds, with struggling parents who can’t afford private swim classes for their kids.”

Jimmy Barrera, 17, from Maspeth, Queens, a junior, said, “When I first came here, I was scared of the water — that’s the truth.”

Now he can swim the 50-yard sprint in under 26 seconds, nearly 10 seconds faster than the 35 seconds the city requires for a certified lifeguard.

Jimmy said he earned $6,000 last summer working at a public pool in Bushwick, Brooklyn, and he hopes to be selected as an ocean lifeguard at Rockaway Beach, Queens, which many young lifeguards covet for its urban “Baywatch” scene.

The city’s Department of Parks and Recreation has nearly 1,500 lifeguards working this year, enough to staff its eight beaches, which opened on Memorial Day weekend, as well as its 53 outdoor pools, which open in late June, said the department’s first deputy commissioner, Liam Kavanagh.

But for many years, the city had problems finding enough young swimmers willing and qualified to become lifeguards. Short-handed and forced to close off sections of beaches and shorten pool hours, the city resorted to recruiting lifeguards from the suburbs and even from overseas.