Car batteries are considered normal maintenance items on a car or any other vehicle and are not usually covered under warranty.
If you bought the car and it's still under warranty though and the battery failed within 6 months or a year then the cars warranty might cover it but there's no guarantee.
Still the dealership may replace the battery at no charge if it was a defective car battery that died or failed sooner than it was supposed too.
But if the battery has lived out it's lifespan then the battery is not covered by the dealership or under warranty and you would have to pay for the replacement battery yourself.
Batteries typically last 4 to 8 years depending on the brand and quality of the battery and your climate.