Java Programming
primer-original-v2mediumJava Programming03 Class And Objects, Date Apiprimer-original-v2

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

Quick AnswerThe correct answer is this() because it directly addresses the core logic of Java Programming.

This question has been retained as-is due to its unique context.

Related Java Programming questions

Practice more Java Programming questions

PrimerPrep has independently reviewed practice questions and coding exercises — all free.