Java Programming
Accenture PrimermediumJava Programming03 Class And Objects, Date Api

Accenture Java Programming Practice Question

Observe the below class. class Product{ int productId; String productName; Product { productId=0; productName= ; } Product(int id, String name) { //access Product() ---- Line 1 productId=id; productName=name; } } Identify the valid option which is used to invoke the no argument constructor, Product(), at Line 1.

Answer options

A
this()
B
Product()
C
super()
D
new Product()

Correct answer: this()

Explanation

this() calls the no-argument constructor of the same class within a constructor.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

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