Nearly 30 D.C. police officers and firefighters testified yesterday against the city's residency law for city workers, arguing that the requirement that they live in the District has forced them to endure economic hardships and, in the case of some police officers, unnecessary danger.

The City Council's Government Operations Committee, which held the hearing, is considering two bills to exempt police officers and firefighters below the rank of lieutenant from the residency requirement and a third proposal to make residency a preferential qualification for applicants for all city government jobs.

The residency law went into effect in 1980 and with some exceptions requires nonresidents hired by the District government to move into the city within 180 days or risk losing their jobs. For nearly eight hours, many of the witnesses called to testify insisted that the law has been a detriment to their personal lives.

Richard Sterne, residency chairman for Local 36 of the International Association of Fire Fighters, said that nonresidents who accepted jobs thought they could abide by the residency law until they encountered serious financial problems in raising families.

"Our members and most other city workers are not highly paid and cannot afford to live comfortably in this city on our salaries, but we can afford to buy homes in the lower-priced suburban areas," Sterne said. "This is not an anti-District of Columbia issue and it is not a racial issue. It is pure and simple an issue of economics -- of getting the most bang out of our bucks."

However, many of the police officers who testified said they were far more concerned about the personal risks involved in having to live in a city they patrol than the financial difficulties.

Some said that a departmental requirement that they carry their guns during off-duty hours means that stress is a constant companion. Others told of having to watch their families endure physical and verbal abuse because they are related to police officers and of unpleasant encounters with persons they had previously arrested.

Police officer Deborah K. Pendergrass testified that she and her young daughter had gone to a fast food restaurant for dinner and met a man in line who repeatedly said, "I know you . . . . Yea, that's the . . . cop who locked me up."

"My daughter must have sensed trouble," Pendergrass testified. "She started crawling up into my arms. It was at that moment I felt helpless -- no uniform for identity, or police radio to call for backup, not even a telephone to call 911, just a cold service revolver at my side and a small child in my arms."

The council committee members are deliberating whether such problems warrant exempting police and firefighters from the residency regulations.

City Council member William R. Spaulding (D-Ward 5), committee chairman, said his major concern is whether the residency law is having a negative impact on the city's ability to find qualified employes.

Council member Nadine P. Winter (D-Ward 6) said she is against the proposed exemptions, explaining that "If it is good enough for you to earn a salary here, it is good enough for you to live here."

In recent months, the city's personnel office has challenged the residency status of a number of police officers and firefighters. Council member Carol Schwartz (R-At Large), who introduced the bill to exempt firefighters, said she believes the city is "picking" on its public safety employes.

"Let's practice what we preach in our executive branch -- equal rights under the law," said Schwartz.

Outside the hearing room, Mayor Marion Barry told reporters that "the law is carried out fairly" and that the "quality of our police and firefighters has increased since the law went on the books."

A draft copy of a study of the impact of the residency requirement, prepared by the D.C. Office of Personnel, shows that between May 1, 1984 and April 30, 1985, the District's fire, police and corrections departments hired higher percentages of nonresidents than other city departments. Of the 849 public safety employes hired during that period, 347 or 41 percent lived in Maryland or Virginia when they were hired.

Overall, the report states that the vast majority of the 3,910 employes hired during the period surveyed were District residents -- 82 percent compared to 81.3 percent for the previous year. The study concludes that "qualified District residents continue to be available to meet the great majority" of the city's vacancies.

During yesterday's hearing, D.C. Personnel Director Clinton A. Hilliard said that more than 59 percent of the city's work force is composed of D.C. residents and that an increase of about 1,500 resident employes in recent years has boosted personal income tax revenues by about $1.7 million.

Hilliard also said that, in the past, exemptions from the residency requirement have been based on the District's inability to find and retain a sufficient number of qualified persons for a particular position.

"There is no hardship experienced by the police and fire departments in the recruitment and retention of police and fire employes," he said.