1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
polet [3.4K]
3 years ago
11

Demonstrate constructor overloading by both declaring relevant constructors of your choice and invoking them. [

Computers and Technology
1 answer:
mixas84 [53]3 years ago
4 0

Answer:

Constructor overloading means constructor having same name but different signature

Parameter of constructor are depend upon

Number of parameter

Type of parameter.

Sequence of parameter

When we create an object of an class the compiler determines which type of constructor is call by comparing its signature of constructor.

For example:

Following are the constructor overloading  program in java

class abc // creating class

{

 int r;

 String name;

abc(int r1)        // Constructor 1

 {

 r = r1;

System.out.println(r);

 }

 abc(String n1)        // Constructor 2

 {

 name=n1;

System.out.println(name);

 }  }

class Main  // main class

 {

 public static void main(String[] args) // main method

  {

    abc  ob=new abc(1);  // object 1

     abc S2 = new abc("Sumit");  // object 2

       }

 }

Output:

1

Sumit

In this program, we have two constructors.

object 1 will call constructor 1 because  the signature of constructor 1 is matched to the statement 1.  

object 2 will call constructor 2 because  the signature of constructor 2 is matched to the statement 2

You might be interested in
Is media good for the brain?
skad [1K]

Of course yes, and that depends of the type of content that you eaten =D

Media is a source of good information for to create your opinion.

Best regards

7 0
3 years ago
Read 2 more answers
company gives the following discount if you purchase a large amount of supply. Units Bought Discount 10 - 19 20% 20 - 49 30% 50
ratelena [41]

Answer:

In Python:

order = int(input("Order: "))

discount = 0

if(order >= 10 and order <20):

    discount = 0.20

elif(order >= 20 and order <50):

    discount = 0.30

elif(order >= 50 and order <100):

    discount = 0.35

elif(order >= 100):

    discount = 0.40

price = order * 4.1

discount = discount * price

print("With your order of "+str(order)+" items, the total value will be $"+str(round(price,2))+" with a discount of $"+str(round(discount,2))+" for a final price of $"+str(round((price-discount),2)))

Explanation:

This prompts the user for number of orders

order = int(input("Order: "))

This initializes the discount to 0

discount = 0

For orders between 10 and 19 (inclusive)

if(order >= 10 and order <20):

-----------discount is 20%

    discount = 0.20

For orders between 20 and 49 (inclusive)

elif(order >= 20 and order <50):

-----------discount is 30%

    discount = 0.30

For orders between 50 and 99 (inclusive)

elif(order >= 50 and order <100):

-----------discount is 35%

    discount = 0.35

For orders greater than 99

elif(order >= 100):

-----------discount is 40%

    discount = 0.40

This calculates the total price

price = order * 4.1

This calculates the pre discount

discount = discount * price

This prints the report

print("With your order of "+str(order)+" items, the total value will be $"+str(round(price,2))+" with a discount of $"+str(round(discount,2))+" for a final price of $"+str(round((price-discount),2)))

3 0
3 years ago
Gary lives in an area that receives high rainfall throughout the year. Which device would be useful to him to maintain his compu
-BARSIC- [3]

The correct answer is B.UPS

A UPS or Uninterruptable Power supply makes sure that you have backup in case there is a power outage in your area. It provides ample time for you to save all files before shut down.

6 0
3 years ago
Read 2 more answers
Look at the following structure declaration.
myrzilka [38]

Answer:

B. a tag

Explanation:

In the structure definition given below:

struct Employee

{

string name;

int idNum;  

};

Employee corresponds to the tag of the structure. The tag is used to create additional instances of the structure. For example:

struct Employee e1;

struct Employee e2;

name and idNum are members of the Employee structure and are referenced using the dot notation. e.g.,

struct Employee e1;

e1.idNum=1;

7 0
3 years ago
Ethereum Mining Calculator Profitability and Difficulty Level?
yanalaym [24]

Profitability Calculator: https://www.cryptocompare.com/mining/calculator/eth?HashingPower=200&HashingUnit=MH%2Fs&PowerConsumption=140&CostPerkWh=0.12&MiningPoolFee=1

Difficulty Level Chart: https://www.coinwarz.com/difficulty-charts/ethereum-difficulty-chart

3 0
3 years ago
Other questions:
  • Which action is LEAST important to maintaining a healthy credit score?
    8·2 answers
  • Need help answering this
    7·1 answer
  • Once you select select a crop boundary, you can no
    15·1 answer
  • Assume you previously entered these lines of code.
    14·2 answers
  • As a consommé simmers, the meat and eggs coagulate, forming a
    6·1 answer
  • What language must be used to display a bare-minimum webpage?
    8·2 answers
  • A laptop gets recycled by an e-waste recycling company once it can't be used anymore. Which stage of the hardware lifecycle does
    7·1 answer
  • Which of the following is an example of an output device
    13·1 answer
  • Describe four traditional tehniques for collecting information during analysis.
    11·1 answer
  • Mention any
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!