Java Programming
Accenture Technical 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

Quick AnswerThe correct answer is Compilation fails because it directly addresses the core logic of Java Programming.

Correct answer: Compilation fails.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerPrep has 1400+ practice questions, 2026 simulations and coding hands-on — all free.

Watch Walkthroughs!