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

Write a Java program that implements concepts from any or all of the following,

ID: 3712327 • Letter: W

Question

Write a Java program that implements concepts from any or all of the following, polymorphism, recursion, arraylist, GUI, sorting algorithms. It can be a fun little game like blackjack for example. Just some fun. Heavily commented as well so I may understand. Write a Java program that implements concepts from any or all of the following, polymorphism, recursion, arraylist, GUI, sorting algorithms. It can be a fun little game like blackjack for example. Just some fun. Heavily commented as well so I may understand.

Explanation / Answer

SOLUTION:- Java Program that implements concept of compile time polymorphism via constructor overloading :-

class add // creating a class named add
{
int a,b,c,d,e; //declaring variables
public add(int x,int y) // defining parameterized constructor with 2 parameters
{
a=x;
b=y;
}
public void addition() // declare method named addition() with return type void
{
c=a+b;
System.out.println(c); // print the value of c
}
public add(int x,int y,int z) // defining parameterized constructor with 3 parameters
{
a=x;
b=y;
c=z;
}
public void multi() // declare method named multi() with return type void
{
d=a*b*c;
System.out.println(d); //// print the value of d
}
}
public add(int x,int y,int z,int w) // // defining parameterized constructor with 4 parameters
{
a=x;
b=y;
c=z;
d=w;
}
public void sub() // declare method named multi() with return type void
{
e=a-b-c-d;
System.out.println(e); // print the value of e
}
}
class parameter1 // creating a main method class
{
public static void main(String args[]) // main method
{
add r1=new add(10,20); // Perform constructor overloading via paasing 2 argument values at the time of //creating the object r1
add r2=new add(10,20,30); // Perform constructor overloading via paasing 2 argument values at the time of //creating the object r2
add r3=new add(100,10,10,10); // Perform constructor overloading via paasing 2 argument values at the //time of creating the object r3
r1.addition(); // method addition calling with object r1
r2.multi();    // method multi calling with object r2  
r3.sub() ; // method sub calling with object r3

System.out.println("Constructor Overloading Completed that is Compile Time Polymorphism");
}
}

====================================================================================

OUTPUT:-

30

6000

70

Constructor Overloading Completed that is Compile Time Polymorphism

=================================================================================

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