Q1. Assume that class Item has following two private data fields: private String name; private int code; and following constructor: public Item(String n, int c) { name = n; code = c; } Now, we want to...


Q1. Assume that class Item has following two private data fields:<br>private String name; private int code;<br>and following constructor:<br>public Item(String n, int c) { name = n; code = c; }<br>Now, we want to write a class called Electronicltem that inherits the<br>properties of class Item as follows having only one data field:<br>public class Electronicltem extends Item {<br>private double price;<br>The constructor of class Electronicltem can be written as follows:<br>3. public Electronicltem(String n, int c, double p)<br>{ this(n, c); price = p; }<br>O b. public Electronicltem(String n, int c, double p)<br>{ super(n, c); price = p; }<br>O c. public Electronicitem (String n, int c, double p)<br>{ Item.super(n, c); price = p; }<br>%3!<br>O d. public Electronicitem (String n, int c, double p)<br>{ Item.name = n; Item.code = c; price = p; }<br>

Extracted text: Q1. Assume that class Item has following two private data fields: private String name; private int code; and following constructor: public Item(String n, int c) { name = n; code = c; } Now, we want to write a class called Electronicltem that inherits the properties of class Item as follows having only one data field: public class Electronicltem extends Item { private double price; The constructor of class Electronicltem can be written as follows: 3. public Electronicltem(String n, int c, double p) { this(n, c); price = p; } O b. public Electronicltem(String n, int c, double p) { super(n, c); price = p; } O c. public Electronicitem (String n, int c, double p) { Item.super(n, c); price = p; } %3! O d. public Electronicitem (String n, int c, double p) { Item.name = n; Item.code = c; price = p; }

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here