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 ElectronicItem that inherits the properties of class Item as follows having only one data field: public class ElectronicItem extends Item { private double price; The constructor of class ElectronicItem can be written as follows: public ElectronicItem(String n, int c, double p) { this(n, c); price = p; } public ElectronicItem (String n, int c, double p) { Item.super(n, c); price = p; } public ElectronicItem (String n, int c, double p) { Item.name = n; Item.code = c; price = p; } public ElectronicItem(String n, int c, double p) { super(n, c); price = p; }
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 ElectronicItem that inherits the
properties of class Item as follows having only one data field:
public class ElectronicItem extends Item {
private double price;
The constructor of class ElectronicItem can be written as follows:
-
public ElectronicItem(String n, int c, double p)
{ this(n, c); price = p; }
-
public ElectronicItem (String n, int c, double p)
{ Item.super(n, c); price = p; }
-
public ElectronicItem (String n, int c, double p)
{ Item.name = n; Item.code = c; price = p; }
-
public ElectronicItem(String n, int c, double p)
{ super(n, c); price = p; }
![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 Electronicitem that inherits the
properties of class Item as follows having only one data field:
public class Electronicitem extends Item {
private double price;
The constructor of class Electronicltem can be written as follows:
public Electronicltem(String rnt c, double p)
A
{ this(n, c); price = p; }
public Electronicltem (String n, int c, double p)
B
В
{ Item.super(n, c); price = p; }
public Electronicitem (String n, int c, double p)
{ Item.name = n; Item.code = c; price = p; }
public Electronicltem(String n, int c, double p)
D
{ super(n, c); price = p; }](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb7fa3a6a-fa99-44ff-9126-7b82978e4fc2%2F79ea0bc9-321f-4535-94f7-9b8b55f249d5%2Ff3bpozo_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)