I have an abstract class Product
public abstract class Product implements Serializable {
private Integer id;
private LocalDateTime creationDate;
private LocalDateTime updateDate;
//constructors etc..
}
then I have multiple child classes that extend Product and an Ad class which lists the products. My question is: can I use the Product class as an attribute? so it could be instantiated with the different child classes like this:
public class Ad implements Serializable {
private Integer id;
private Product product;
//constructors and methods..
}
Ad example = new Ad(1,childClass);
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)