Without getting a balanced diet and only exercise in the gym, can I get a six-pack body?
You are basically asking a question like:
Can i build a house without the bricks?
Can i build a house without the windows or doors?
The answer is plain and short, no, you need the bricks, the doors and the windows, otherwise there is no point on building a house that will get shattered in no time or the house that you can't enter because it lacks doors or when you enter you can't leave.
So without your diet there is no point on exercising if you are aiming for purely looks and aesthetics, you are just going to waste your time and you will never achieve them. Unless you wan't to become healthy, retain strength and gain endurance and you don't care about looks then go for the exercise, it's healthy overall, it will help you both mentally and physically.
Without a foundation you can't build a house. Your foundation is your diet, how you eat that's how you is.
That's why many people fail on fitness especially, when they start to workout they end up even fatter then they were before, because they think just because they have burned around 300–500 calories they can eat whatever they want and not gain an inch.