Question

In: Computer Science

Answer the following Java questions with True or False: a) Java supports Multiple Inheritance in a...

  1. Answer the following Java questions with True or False:

a) Java supports Multiple Inheritance in a way that a class can inherit from multiple classes as long as they do not have the overridden methods. (T/F)

b) A class in Java cannot implement more than one interface. (T/F)

c) A class is in instance of an object (T/F)

d) In Java a class can implement multiple interfaces only if that class inherits from another base class (T/F)

e) Constructors are not inherited by the derived class (T/F)

f) Every recursive method must have a base case or a stopping condition (T/F)

g) When a class overrides a method of a superclass, the name, parameter list and the return type of the two methods do not have to be identical (T/F)

h) The running time for a binary search algorithm is O(N logN) (T/F)

i) All sorting algorithms are of order O(logN) (T/F)

Solutions

Expert Solution

a) False. Java does not support multiple inheritance as if two classes have same methods it will result in ambiguity. But even if they don't have the same methods java does not support it as this check is done during compile time and not runtime. So class cannot inherit from multiple classes as it will give compile error.

b) False. A class can implement more than one interfaces. This is because interface is just an abstract they do not have the implementation details of the methods.

c) False. A class is a concrete thing, it is the blueprint using which an object is created. So object is an instance of class.

d) False. A class can implement multiple interfaces without any conditions.as interfaces are abstract all their methods need to be defined in the class.

e) True. Constructors are special they have the same name as the class. So if a constructor is inherited by the derived class then it would violate that constraint.

f) True. The base case or stopping condition helps the recursive method to terminate. Without this the program might show unexpected behaviour

g)False. To override a method it needs to have these features- same name,same number of parameters,same type of parameters,same return type

h) False . The running time of binary search is O(logn). The maximum running time for searching an array with n elements is O(n) so the time cannot be greater than this.

i)False. Bubble, selection, insertion sort algorithms in worst case take O(n​​​​​​2​​​​​)


Related Solutions

Answer the following questions True or False. Write “True” or “False” in the blank. 1._________ The...
Answer the following questions True or False. Write “True” or “False” in the blank. 1._________ The rate constant changes if the concentrations of the reactant change. 2._________ If the concentration of a reactant changes, the rate of the reaction always changes. 3._________ The coefficients of the overall reaction tell us the order for each reactant. 4._________ The half-life for a first order reaction does not depend on the initial concentration. 5._________ If the rate of a reaction over a long...
For the following questions: write a TRUE or FALSE and then elaborate on the answer. The...
For the following questions: write a TRUE or FALSE and then elaborate on the answer. The golden-rule state for an economy with constant population but where the effective supply of labour grows at a steady rate refers to a condition such that consumption of the total population is maximised. The equation, Y = MV/P, implies that, if the velocity (V) does not change when the money supply (M) changes, then the government can raise national income (Y) by printing more...
Answer the following statements as true or false, then select the correct multiple -choice answer:   1.   If...
Answer the following statements as true or false, then select the correct multiple -choice answer:   1.   If dividends are declared during the year the company would close the dividend account by debiting retained          earnings and crediting the dividend account.   2.   A company that forgets to recognize depreciation for the year understates its income and assets.   3.   Prepaid insurance expense will have a zero balance on the after closing trial balance.   4.   Retained earnings on an adjusted trial balance is the beginning retained earnings for...
Indicate if the following questions are True or False. Explain “Why” your answer is True or...
Indicate if the following questions are True or False. Explain “Why” your answer is True or False. 1. Marginal costs tend to increase faster than average variable costs as firms produce more. Why? 2. Competitive firms try to become monopolistic firms. Why? 3. For a monopoly, marginal revenue is less than average revenue or demand for any given level of firm production except for its first production unit. Why? 4. Some oligopolistic firms try to collude. Why?
True/ False Questions: For the following questions, first write whether they are true or false then...
True/ False Questions: For the following questions, first write whether they are true or false then write in a few sentences why it’s true or false. (1.5) a. The processes for producing penicillin and blue cheese both use the Penicillium fungus.     b. The reproductive organs of Amanita muscaria are popular pizza toppings.     c. The fungus Claviceps purpurea is thought to have triggered the infamous Salem witch trials.     d. Saccharomyces cerevisiae is a common household bread mold.    ...
PART 6: True or false and multiple-choice questions Question 16: True or false, firms in situation...
PART 6: True or false and multiple-choice questions Question 16: True or false, firms in situation of monopolistic competition have deadweight losses associated with monopoly because of barriers to entry. Question 17: Which of the two demands functions below is most elastic A) Qa=100-2p B) Qb=120-p Question 18: If a buyer values an object for $4 and a seller’s cost is $1, which of the statements below is false! If a transaction takes place, total surplus will be equal to...
Question5. Please answer the following questions as either "TRUE" or "FALSE" (Write out either “True” or...
Question5. Please answer the following questions as either "TRUE" or "FALSE" (Write out either “True” or “False”) A. A normal distribution is characterized by its mean and its degrees of freedom. ______________ B. A paired t-test is considered a nonparametric test. ______________ C. A 93% confidence interval for µ is that numerical interval constructed to contain 93% of the values of µ. ____________ D. A 94% confidence interval for a mean is narrower than a 93% confidence interval. ______________ E....
True or False Questions: Please answer true or false. 1. Even when care is free at...
True or False Questions: Please answer true or false. 1. Even when care is free at the point of service, we would expect low and high-income individuals with the same level of need to demand different quantities of health care. 2. We would expect the demand curve for physician visits to be more price elastic than the demand curve for inpatient hospital care. 3. A decision by the provincial governments to include counseling by psychologists within the public insurance plan...
Please answer these TRUE or FALSE questions. 1. True or False. The Born-Oppenheimer approximation accounts for...
Please answer these TRUE or FALSE questions. 1. True or False. The Born-Oppenheimer approximation accounts for scattering. 2. True or False. Tunneling is one way to approximate the solution to the Free Particle. 3. True or False. The coordinate version (x,y,z) of the Free Particle wavefunction can be normalized by including time. 4. The spin quantum number is used when combining the Hydrogen Atom and Free Particle models together.
Answer fifteen (15) of the following true or false questions. Put a “T” or “F” at...
Answer fifteen (15) of the following true or false questions. Put a “T” or “F” at the end of the statement. 1) An increase in the interest rate would shift the consumption function upward. 2) The slope of the consumption function equals the marginal propensity to consume. 3) The marginal propensity to consume measures the change in consumption divided by the change in income. 4) A decrease in the price level decreases net wealth and increases consumption spending. 5) The...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT