Getting a B in AP Computer Science A

Would it look bad if I got a B in AP Computer Science, but ended up getting a 4 on the exam, especially since I want to major in comp science.

Look bad to whom? For what?

If you’re applying to MIT/CMU/Stanford CS, with hundreds of A/A+/5 applicants, that one data point would be a disadvantage.

But it’s one of 30+ grades from HS, plus standardized tests, essays, etc., etc.

I’m assuming you don’t have the option to change it, so wondering how others will look at isn’t really productive. Focus on the future, which you can control.

I am thinking about selective universities like UCSD, UCI, Cal Poly SLO, UCSB

And I am thinking if the B will really hurt my advantages, then I will consider switching my major before applying

CS is a very competitive major. If you switch it before applying, you may face an uphill battle, once in college, if you decide you want to major in CS after all. Do you have other CS credentials on your application, besides the one class?

For the Cal States and UC’s mentioned, you pretty much need a direct admit into CS to have a chance of pursing that major. Changing majors can be problematic and many times not possible. One B will not be an automatic rejection, but your overall GPA will be more of the determining factor. How are you doing in your other classes especially Math/Physics? What are your test scores? As stated above, do you have any other CS related coursework or EC’s that show your strength in this subject?

It’s doubtful if getting a B on any one class will impact things. Your overall GPAs and overall rigor along with test scores, essays and ECs will weigh way more.

As mentioned above, almost all of those schools listed above, you pretty much need to direct entry into CS.

A B in the class and a 4 on the AP test is the same thing.
Any time you are thinking about majoring in something, you need to think about how you did in a class related to that major, how much work it was for you, and if you enjoyed it.