What is the output of the following code:
class Course { String courseName; Course() { Course c = new Course(); c.courseName = "Oracle"; } } class Main { public static void main(String args[]) { Course c = new Course(); c.courseName = "Java"; System.out.println(c.courseName); } }
D
This class will throw StackOverflowError at runtime.
The constructor of the class Course creates an object of the class Course, which will call the constructor again.