Yes, you can self-learn for a degree,  you can earn a bachelor's or master's degree by taking tests instead of classes. However, learning is hard and it is extremely challenging. You'll have to self-learn the basics, then intermediary and advanced materials, not all students have the motivation to learn something on their own.