An inmate at the Prince George's County Detention Center testified in court yesterday that last November, at least two other inmates beat him and attempted to assault him sexually in a cellblock. The alleged victim, James A. Anderson Jr., said that guards did not respond to his cries for help. Inmates did, but they came only to watch, he said.

Anderson's testimony came in the first day of the trial of Ronald P. Garnett, who is charged with attempted sexual assault in the alleged November incident. Garnett, who says he is innocent of the charges, is the first of 12 former or current inmates that the state's attorney plans to prosecute either for sexual offenses or attempted sexual offenses during several separate incidents. The 12 inmates were indicted by a grand jury that was impaneled last October following a Washington Post series on rapes and sexual assaults in the county jail.

Anderson, a Pennsylvania janitor who pleaded guilty to first degree murder and was sentenced to 30 years last week, testified yesterday that last Nov. 27, Garnett, 24, and Kirk Williams, 27, asked Anderson to come into Williams' cell. Anderson said that the men then asked "whether or not I was gay." Anderson testified he told him he was not, and that then both Garnett and Williams ordered him to perform sexual acts on them.

Anderson testified that he refused their demands, that the two then punched him repeatedly, and that Garnett held him while Williams sexually assaulted him with pencils. Later, Anthony Majette, 22, entered the cell for a short time, Anderson said. Both Williams and Majette have been indicted on charges of attempted sexual assault. Majette has denied the charge, and there is a warrant out for the arrest of Williams, who is now out of jail.

Evidence presented by Assistant State's Attorney David M. Simpson showed that Anderson gave a similar description to Prince George's County police the day after the assault allegedly took place. However, Garnett's attorney, Richard H. Sothoron Jr., told the court that earlier this year Anderson had sent two statements to the state's attorney asking that the charges against the three men be dropped.

Under examination by the prosecution, Anderson acknowledged that he had written the two statements because he feared the accused would seek retribution if he testified. In response to a question from Circuit Court Judge Audrey Melbourne, he said he was afraid "I may be incarcerated with them the defendants ," and that he was afraid of "constantly being in a fight . . . . It's like fire and gasoline."

Anderson said that on one occasion inside the jail, after the alleged incident, he heard Garnett say, "I'm going to kill the punk." Anderson has been in protective custody at the jail since the alleged assault took place.

"What James Allen Anderson Jr. alleges did not happen at all," Sothoron told the all-male jury in his opening statements. Sothoron told the jury that Anderson's charges were a "con" because he was worried about the outcome of his murder trial.

"It's a bizarre case," Simpson said after yesterday's proceeding. "Our normal witnesses are not convicted murderers."