Accenture Java Programming Practice Question
Given: public class Message { String msg; int noOfWords; public Message() { msg += " Thank you"; } public Message(int noOfWords) { this.noOfWords = noOfWords; msg = "Welcome"; Message(); } public static void main(String args[]) { Message m = new Message(5); System.out.println(m.msg); } } What will be the output ?Answer options
A
Welcome
B
Welcome Thank you
C
Welcome Thank you 5
D
Compilation fails
E
An exception is thrown at runtime f. The code runs with no output
Correct answer: Compilation fails
Explanation
Correct answer: Compilation fails.