Yes, both are correct, but 'can you swim?' is the usual way of saying it. It would normally be understood as asking "do you know how to?", as opposed to "are you allowed to?" or "are you physically capable of it?", both of which are possible meanings with the right context.
True that John. You gotta ready your mind first before exercise. Btw, I have resumed swimming now. Doing 4 days a week.