4 years old is a hard age, developmentally.
It may just be, that in a classroom, there are SO many other kids... and it may be over-stimulation or more 'competition' for things... and socialization. Many things, can tweak a child and make them act out... because they don't know how to cope... with other social nuances.... thus they hit. They are frustrated....
IN addition to rewards or consequences, you ALSO have to teach a child, other ways of coping/acting. If not, a child will NOT learn, other 'behavior' for frustrations. So, instead of just scolding for the hitting... the child has to learn other ways of behaving.... giving them SKILLS.
Because, without learning alternate skills for a frustration... a child will still not know how to 'cope' with a frustration. And also give him words, for how he can say/communicate... a frustration.
A young child has to be 'taught'... in addition to consequences.
Sure a child can learn what is good/bad behavior. BUT, that does not mean they 'automatically' know alternate ways of reacting... to things that frustrate them. Thus, the problem can continue. So you have to teach him... OTHER ways of expressing.... good or frustrating feelings. He can say it, tell someone, go away from the person that is irking him, he can say that he wants a turn, he can tell the other kids to share, he can tell the Teacher if something 'wrong' is happening... he can go and find other friends... he can go and do something else, he can say he is frustrated too. He can be taught, WHO to go to for 'help' or anything that bothers him etc.
A child does NOT necessarily "know" other options... that they can do, unless you teach them and talk to them about it. Thereby, giving them 'problem solving' skills....
all the best,
Susan