When a police officer wishes to question you, his actions generally fall under one of three areas: CONTACT, DETENTION, or ARREST. During CONTACT, you may be questioned, but you have the right to refuse to answer, AND the right to walk away from a Contact.
On the other hand, a DETENTION is a non-consensual temporary denial of liberty to leave. All this means is you cannot simply just walk away or leave while an officer investigates their suspicions. You may and SHOULD however always still REFUSE TO ANSWER QUESTIONS. Additionally, the officer only has a “reasonable” amount of time to determine if there is probable cause for an arrest or they must release you.
Courts have determined that what is considered a reasonable amount of time is relative to the criminal activity being investigated. It is important to note that such a detention is not a formal arrest, and physical restraint is not an essential element of a detention.