It wasn’t the typical courtroom exchange between a judge and defendant. Twenty years ago, it would have seemed preposterous.

But that was before the borough established its groundbreaking treatment court in 1998.

On Wednesday, Judge Marcia P. Hirsch looked at the young man standing in front of her and participated in a probing conversation as she questioned him about his substance abuse treatment progress.

“You’re there three times a week?” she asked.

“Yes, I’m headed there right after this,” he said.

“And what do you talk about in your groups there?” Hirsch said, continuing her line of questioning.

As the young man answered, he and Hirsch talked about his childhood issues and strategized about how he could avoid sliding into the same pattern of abuse that landed him in court in the first place.

The conversation continued for a few more minutes as Hirsch discussed with the man about work, how his last drug test went, how his home life was, what day of the week works best for a return to court. Finally, she dismissed him.

“Keep up the good work,” Judge Marcia Hirsch said to the young man before he headed out the courtroom door.

The strikingly informal, almost friendly interaction, is an example of what happens in Queens Treatment Court, or QTC, a special problem-solving court located on the third floor of the Queens Criminal Courthouse in Kew Gardens.

QTC handles drug-fueled felony cases while the Queens Treatment Misdemeanor Court (QTMC), which is located on the ground floor, connects certain defendants to services such as rehab or mental health treatment.

To opt into the QTMC, defendants must agree to a plea deal and commit to a treatment program. If they stick with it and succeed, they avoid jail time and may even get their charges dismissed or reduced.

“Up here the focus is not on guilt or innocence. It’s on the clinical aspects of the client’s mental health,” said Robert Sharoff, a lawyer with Queens Law Associates who has worked in the Queens Treatment Courts for about 15 years. “You do see people really change and that’s really satisfying.”

Sharoff said that one of the key parts of the QTC is that it gives control of the situation back to the defendant.

In trial, the result is out of their hands, but in QTC, they received a set of conditions in the form of a contract. After that, success lies in their ability to meet the conditions and work on getting sober.

The drug court within QTC was established in 1998 as an alternative to incarceration for non-violent drug offenses. The program was initiated by Justice Kenneth Holder, then the head of the District Attorney’s Narcotics Trial Bureau, and former Administrative Judge Alfred Lerner.

The QTC has since expanded to include special courts for people charged with driving while intoxicated, veterans and people with mental health issues. There is a also a statutory court that judges can send defendants to without the prosecutor’s approval.

The courts take a non-adversarial approach unlike the traditional criminal courtrooms.

Instead of the defense and the prosecution taking opposing sides, everyone — the judge, the prosecutor, the defense attorney and the appointed social worker — works as a team to help the defendant address the substance abuse and related issues, that got them arrested and charged.

Together, they make sure the defendant has access to whatever services they need to succeed, from housing and therapy to job training and G.E.D. programs.

The hope is that defendants leave the court program better off than when they started, said Patricia Faraglia, a court liaison for the Department of Education.

But it’s not a completely touchy-feely approach.

“It’s holistic but you’ve got to remember we’re sitting in a courthouse. A crime has been committed,” she said.

On Wednesday morning Faraglia watched a young man who she said she had worked with walk into the courtroom. His hands were cuffed behind his back and he was flanked by two court officers. The young man had failed the program and was in court that day for his sentencing.

“He tried. There were some really good moments for him,” she said. “I’m sad to see him go. I know how hard he worked.”

After a polite exchange with Hirsch, the young man listened impassively as she read off his sentence: Two years in prison.