Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I need some help with the following questions in Java: public class Poly

ID: 3691888 • Letter: H

Question

Hello, I need some help with the following questions in Java:

public class Poly { private String name; private Poly next; public Poly() { narae="Poly"; next = null; } public Poly(String n) { name = n; next = null; } public void setName(String n) { name = n; } Public String getName() { return(name); }public poly grtNext () { return (next); } public void setNext (poly p) { next = p;} } public class Rect extends Poly{ private Rect next; public Rect() { super("Rect");next = null; } public Rect getNext() { return(next);} public void setNext(Rect r) { next = r; } public class ShapeList { private Rect rhead; private Poly phead; public ShapeList() { rhead = null) phead=phead = null; } public Poly getPhead() { return(phead);} public Rect getRhead() { return(rhead);} public void insert(Poly p) { p.setNext(phead); phead = p;} public void insert(Rect r) { r.setNext(rhead); rhead = r;} public void delete() { if (rhead = null) phead=phead.getNext(): if (rhead != null) rhead=rhead.getNext():} } public static void main(String[] args) { shapeList s1 = new ShapeList (); s1.insert (new Rect ()); s1.insert (new Poly ()); s1.insert (new Rect ()); poly pit = s1.get phead(); while (pit ! = null) { System.out.printIn(pit.getName()) pit = pit.getNext(); } } Which classes are superclass(es) and subclass(es)? Are any methods being overloaded? If so, which ones? Are any methods being overriden? If so, which ones? Is this list implementing a queue or stack? Explain your answer. What is the output of the program? If the insert (Rect) method in ShapeList class is modified by inserting the line r.setNext(phead); phead = r; what would be the output? Explain your reasoning.

Explanation / Answer

a.Poly is superclass,

Rect is subclass.

as Rect extends Poly.

b. No method is overloaded. Since no two methods have same definition and differ only in their signatures.

c.yes getNext () method is overridden.Since it accesses method of another class of which it is not the object.

d.It is implemeting a queue because it follows the first in first out principle.It fills up the list and then starts from the point of inception and moves till the list is empty.

e.Outut of the program is the queue implementation in java.It follows FIFO implementation.

f. If such modifications are done then every alternate element would be skipped in implementation.

Thank YOU very much. Hope the solutions help.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote