Observe the below class.
class Product
int productld;
String productName;
F
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.
Select one:
O a. Product();
b. Product
O c. this();
O d. super();
Answers
Answered by
8
Answer:
this();
Explanation:
class Product{
int productId;
String productName;
Product( ) {
productId=0; productName="";
}
Product(int id, String name) {
this(); //access Product() ---- Line 1
productId=id;
productName=name;
}
}
Answered by
0
Concept:-
Putting together, organizing, and putting away information works on direction.
Given:-
Given that the question “Observe the below class class Product”
Find:-
We have to find that the correct option of the question, “Observe the below class. class Product” from the given options.
Solution:-
- The correct option of the question is option . this;.
- It's a unique syntactic build which says "summon one more constructor in a similar class". It's called an "unequivocal constructor conjuring" (or, even more expressly, an "other constructor bring"), and can appear as the fundamental declaration in the constructor.
Hence, the statement “Observe the below class class Product” Is option . this;.
#SPJ3
Similar questions