Indeed, it’s very important to know your rights
Although legally if a cop asks you any question related to the investigation they must give you the Miranda warning that tells you the right to remain silent
In your example if the cop never gave a Miranda warning then it would probably be an inadmissible statement in court