May 2026 Dumps
Accenture Mock 2026mediumMay 2026 DumpsProgramming

Accenture May 2026 Dumps Practice Question

Predict the output of the program: public class JavaIntroduction { String name; int id; double salary; JavaIntroduction(String name, int id, double salary) { this.name = name; this.id = id; this.salary = salary; } JavaIntroduction(JavaIntroduction s) { id = s.id; name = s.name; salary = s.salary; } void display() { System.out.println(name + " " + id + " " + salary); } public static void main(String[] args) { JavaIntroduction s1 = new JavaIntroduction("Harish", 256, 120000); JavaIntroduction s2 = new JavaIntroduction(s1); s1.display(); s2.display(); } }

Answer options

A
Harish 256
B
Harish 256 120000.0 (printed twice)
C
null null
D
Compile time error

Correct answer: Harish 256 120000.0 (printed twice)

Explanation

Demonstrates a copy constructor copying field values from s1 to s2.

Related Accenture May 2026 Dumps questions

Practice more Accenture May 2026 Dumps questions

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