Java Programming
Accenture PrimermediumJava Programming3. Class And Objects, Date Api

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
Compilation fails
C
An exception is thrown at runtime
D
The code runs with no output
E
Welcome Thank you f. Welcome Thank you 5

Correct answer: Compilation fails

Explanation

Correct answer: Compilation fails.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerDumps has 1400+ primer questions, 2026 mocks and coding hands-on — all free.