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

Java Programming CLASS DIAGRAM SECTION Please complete a rows in the table below

ID: 3842797 • Letter: J

Question

Java Programming

CLASS DIAGRAM SECTION Please complete a rows in the table below. public class Polymorphism private protected int 21: double 22: //private protected Polymorphism. zl 2; public void addition (int x, int y) 21 y; System "The f an int and int "+zl void addition (double x, int y) 22 System.out.println ("InThe sum le and int +z2TF public void additi (int x, double y) 22 System out println ("InThe aum of an int and double +22 public void addition (int x, double y, double q) 22 System. out.println InThe aum of an int, double and double +22) void subtraction (int x, int y) //protected private 21 x y; System agt println VnThe di rence between int and int +21) public void traction (double x, int y) 22 x y; System. out prin InThe difference ween double and int z2); class More Poly extends ol public void addition (int x, int y) 21 tore Poly") System out println ("Vnoverride System. out.println ("OverThe aun ofthe gi ra: +zl) System.out println output from More ly") public void subtraction double x, int y) 22 y; System out println ("Vnove rride from More Poly") System. out.println ("The difference between the given numbers: +z2); System out println t from More poly")

Explanation / Answer

A : Its a default constructor that takes no argument which is used to initialise the members of class . It is used to initialise z1 = 2 and z2 = 4

B : We can see that the addition function is overloaded, because the function name is same but the arguments is different. addition function is overloaded with ( int, int) , (double, int) and (int, double)

C : we declare a class named as More_Poly that extends Polynomial class so all the properties of base class polynomial will be inherited by the child class More_Poly.

D: Inside the child class we redefine the base class methods . This is known as Method Overrding. If the child class want to redine parents class method, It can do so by providing its own implemenation.Hence such constructs is known as method Overriding.

E : We declare reference of type polymorphism ,

For the first polymorphism object, we declare its type and hence approprioate methods will be called based on method overloading

For the second object as binding will de decided at run time hence appropriate methods wiull be called at run time

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