Question

In: Computer Science

Which of the following is sufficient for 2 methods to overload? Note: sub/super means the methods...

Which of the following is sufficient for 2 methods to overload?

Note: sub/super means the methods are in two classes that are in an inheritance relationship.

Select one:

a. Same signature, same class

b. Different signature but same name, same class

c. Different signature including different name, same class

d. Different signature but same name, sub/super class

e. If you think more than one of the above are sufficient for 2 methods to overload, select this option

[Java]

Solutions

Expert Solution

Answer :

Different signature but same name, same class is sufficient for 2 methods to overload.

Explanation :

  • Methods overload in the same class only and if we try to define a method with the same name in other class (child class) it is called method overriding with a same signature. So option d is eliminated.
  • Option a is eliminated because it gives an incomplete explanation for the methods. If methods have the same signature and are in the same class but if they have the same name also it leads to error because no method with the same name and same signature is allowed to overload.
  • If the methods have different names and are in the same class, then there is no overloading since both the methods are unique because of their names despite their signature. So option c is also eliminated.
  • Option e is thereby eliminated due to all the above discussions.
  • Now, for two methods to overload, they should have the same name and should be in the same class but should have a different number of arguments or/and different data types for arguments in the two methods i.e should have a different signature. So option b is the correct one.
  • For example, function sam(int, float, float) and function sam(float, int, char) can overload due to different datatypes even if they have the same number of arguments and in the same class.  

Related Solutions

Determine the positive real root of ln(x^2)=0.8 by the following methods. (Note that you need to...
Determine the positive real root of ln(x^2)=0.8 by the following methods. (Note that you need to show the details of your derivations in MATLAB). a) Graphically ( plot the function and copy your figure to word). b) Using two iterations of the bisection method with initial guesses of xl=0.4 and xu=2 and populate the following table. What is the root after two iterations? Provide justification for the values you have obtained in your MATLAB code as comments. i xl xu...
Discuss the three methods of fraud, which means analyze each one and provide an example for...
Discuss the three methods of fraud, which means analyze each one and provide an example for each. The example provided for each method of fraud should be original; meaning not from the book.
Which of the following is mentioned in the text as a possible means by which the...
Which of the following is mentioned in the text as a possible means by which the government may attempt to improve its balance-of-trade position (increase its exports or reduce its imports)? The government could attempt to reduce its home currency's value. The government could require firms to engage in outsourcing. The government could provide subsidies to importers. All of these are mentioned.
There are several scenarios described below. For each of them, do the following (note: R.V. means...
There are several scenarios described below. For each of them, do the following (note: R.V. means random variable) (1) Define the R.V.--- that means something like, “Let X be the number of people who…..” (2) Define the distribution and parameter(s) of the R.V. (3) Give the support of the R.V. (4) Write the probability statement related to the information being sought. Do not calculate the probability. a) Joe is debugging a coding project. From prior experience, he expects to find...
Give 2 examples of vasculogenesis and angiogenesis methods which are currently use in clinics.DEfine methods and...
Give 2 examples of vasculogenesis and angiogenesis methods which are currently use in clinics.DEfine methods and present advantages and disadvantages of methods in detail
Part 2 – Construction Cost A sub-contractor needs to decide which companies they should hire for...
Part 2 – Construction Cost A sub-contractor needs to decide which companies they should hire for each type of building they want to construct. Below is the estimated time it should take (in hours) for each of the different types of buildings they work on. Building Excavating Framing Electrical Plumbing Finishing Office Space 45 100 88 132 312 School 56 250 147 28 290 Apartments 84 480 75 125 244 Grocery Store 95 160 26 78 236 Below are the...
Which of the following statements is most accurate regarding sufficient and appropriate documentation? Audit documentation is...
Which of the following statements is most accurate regarding sufficient and appropriate documentation? Audit documentation is the property of the client, and sufficient and appropriate copies should be retained by the auditor for at least 5 years. Sufficient and appropriate documentation should include evidence that it has been reviewed. Accounting estimates are not considered sufficient and appropriate documentation. If additional evidence is required to document significant findings or issues, the original evidence is not considered sufficient and appropriate and therefore...
Explain the three methods of fraud (Financial Statement Fraud, Occupational Fraud, Collusion), which means analyze each...
Explain the three methods of fraud (Financial Statement Fraud, Occupational Fraud, Collusion), which means analyze each one and provide an example for each.
Describe the three basic methods for contructing a life table (2 main methods, one of which...
Describe the three basic methods for contructing a life table (2 main methods, one of which has 2 submethods). For each one explain how data are collected and entered into a life table. Identify a positive and negative aspect for each.
2. Given the following descriptive statistics, N=18 X bar = 11.5 S sub x = 2...
2. Given the following descriptive statistics, N=18 X bar = 11.5 S sub x = 2 a. find the 95% confidence interval of the population mean u. b. Suppose you know the population standard deviation = 2. What is the minimum sample size that makes the confidence interval length less than 1?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT