Police harassment

Hello i am residing in bangalore coming from a reputed family so recently i was stopped in my area by law and order police and started asking who are u ,where are u going, where do u stay, why are u going in this road etc i obliged and gave all info so mainly i asked them with proper respect way 'why are u asking all these is there any problem or have i commited any offence?' but cops answered aggressively hey u dont have right to ask us anything just shutup and answer what we ask we have power to do anything u dont have any right to ask us anything and they were about to hit me also by their ego even i asked pls can i know from which station are u from still they went angry saying 'i cant say u anything what are u gonna complain are u threating us? should we show our power' and still a lot happned but my question is is asking them why are u asking these details a offence? or against law? all time i talked with them with due respect and entire thing was recorded too but police treated me badly without respect and spoke with me like i was a criminal in front of everyone loudly near place i stay which hurted my image and family respect is what i did was wrong should i bowed my head and left police do anything their will?