A deposition is a discovery tool that lawyers use to gain more information about a case. It is basically an interview that occurs outside a courtroom, where the lawyers will have an opportunity to ask questions of a potential witness. Depositions are generally recorded using audio or audiovisual equipment, and there is usually a court reporter present as well. They typically take place in an attorney's office.
The purpose of a deposition is to learn what a witnesses is expected to say in court. Just like in a courtroom, a lawyer for the opposing side will have a chance to cross-examine the witness to gather more information. The deponent may have an attorney present, though the attorney's job is mostly to make objections. The deponent must still answer questions even if an attorney objects, but the objections can be ruled on later by a judge.
Depositions can impose time and expenses on all parties during litigation. They are not taken in every case. Usually a deposition will not be needed in minor misdemeanor criminal cases such as traffic offenses.
A person who has been charged with a serious felony may be facing a criminal trial, but usually depositions in criminal cases are reserved for other witnesses. A person accused of a crime has a right to remain silent. In some cases, there may be a civil suit pending alongside a criminal case, and the defendant may be asked to testify in the civil case. It is a good idea for a person who is facing a criminal charge or who has been subpoenaed to a deposition to consult an attorney for more information about the process.