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.