Can I have a class A and class B on same switch?

Classful networking has been replaced by CIDR (Classless Inter-Domain Routing). So a more generic form of your question is "Is it okay to have two subnets on the same switch?". The answer to this is in this question (But the summary is that it is okay).

I recommend you spend some time reading Evan's answer to this question, as it is a great overview of subnetting.