Question

In: Computer Science

Which of the following is a motivation for passing functions around in Java? Select one: a....

Which of the following is a motivation for passing functions around in Java?

Select one:

a. Compiled code with anonymous functions is smaller in size than with explicit functions.

(INCORRECT)b. Passing functions as objects around and applying them is significantly less complex than writing the logic for those algorithms directly.

c. It is the only way for the class to allow clients to access data that is otherwise private.

d. It allows clients to provide an algorithm without ownership of the data it operates on.

If we define a class as follows: public class Foo<T extends Bar> { }

Which of the following is a fact that we know about T? Select all that apply.

Select one or more:

a. Foo must define the same methods as Bar.

(INCORRECT)b. T must be a direct subclass of Bar.

c. T objects have access to all of the public methods defined in Bar.

d. T must be Bar or a class that inherits from Bar, directly or indirectly.

Which of the following is an advantage to using an interface as opposed to an abstract class?

Select one:

a. An interface can be the type for a variable declaration.

(INCORRECT)b. A class can inherit a default implementation for a method from an interface.

c. A class can implement multiple interfaces.

d. Interfaces can hold instance variables.

Solutions

Expert Solution

1) Which of the following is a motivation for passing functions around in Java?

Select one:

a. Compiled code with anonymous functions is smaller in size than with explicit functions.

b. Passing functions as objects around and applying them is significantly less complex than writing the logic for those algorithms directly.

c. It is the only way for the class to allow clients to access data that is otherwise private.

d. It allows clients to provide an algorithm without ownership of the data it operates on

--> Option a is correct as passing anonymous functions (lambda expressions) as lamba expressions do no genarate class file which reducs the compiled code and also optimizes the performance.

---------------------------------------------------------------------------------------------------------------------------------------------------

2) If we define a class as follows: public class Foo<T extends Bar> { }

Which of the following is a fact that we know about T? Select all that apply.

Select one or more:

a. Foo must define the same methods as Bar.

b. T must be a direct subclass of Bar.

c. T objects have access to all of the public methods defined in Bar.

d. T must be Bar or a class that inherits from Bar, directly or indirectly.

--> c, d options are correct here. As T is extending Bar class, T is subclass of Bar and it can be direct or indirect and T objects are able to access its super class methods.

--------------------------------------------------------------------------------------------------------------------------------------------------

3) Which of the following is an advantage to using an interface as opposed to an abstract class?

Select one:

a. An interface can be the type for a variable declaration.

b. A class can inherit a default implementation for a method from an interface.

c. A class can implement multiple interfaces.

d. Interfaces can hold instance variables.

--> option c is correct. In java we cannot extend multiple classes into same class, but we can achieve this multiple inheritence only through interfaces by implementing multiple interfaces.

---------------------------------------------------------------------------------------------------------------------------------------------------

If you have any queries, you can always reach out to me through comment section.


Related Solutions

37-1/Which of the following functions is regulated by the hormone melatonin? Select one: _ a. Circadian...
37-1/Which of the following functions is regulated by the hormone melatonin? Select one: _ a. Circadian rhythm _ b. Adaptation to stress c. Start of labor d. Skin pigmentation 2/A 67 years old women with a family history of a Graves' disease, an autoimmune disease characterised by the presence of antibodies directed against thyroid stimulating hormone receptors in the thyroid gland. Her condition is due to: Select one: a. A shortage of B lymphocytes _ b. an implanted "foreign" thyroid...
47. Which of the following statements are correct? Select which option is correct. Select one or...
47. Which of the following statements are correct? Select which option is correct. Select one or more: The level of professional skepticism can be reduced where the auditor has past experience with the entity indicating the honesty and integrity of management. The level of professional skepticism needs to be maintained throughout the whole engagement. Professional skepticism implies an expectation of fraud or error, so is a biased viewpoint. Professional skepticism is not important in considering management's explanations for unusual trends...
1A- Which of the following are possible functions of a protein (select all that apply)? A-Enzyme...
1A- Which of the following are possible functions of a protein (select all that apply)? A-Enzyme B-Trnasport C-Hormone D-Genetic Code 1B- During pyruvate oxidation, pyruvate is oxidized, forming Acetyl Coa. What is the bame of the stage of cellular respiration during which the pyruvate was generated, allowing for pyruvate oxidation to occur? A- Glycolysis B-Oxidative phosphorylation C-Substrate-level phosphorylation D- Chemiosmosis
Which one of the following is an example of a nondiversifiable risk? Select one: a. a...
Which one of the following is an example of a nondiversifiable risk? Select one: a. a well-managed firm reduces its work force and automates several jobs b. a well-respected president of a firm suddenly resigns c. a key employee suddenly resigns and accepts employment with a key competitor d. a well-respected chairman of the Federal Reserve suddenly resigns e. a poorly managed firm suddenly goes out of business due to lack of sales
Which of the following statements are correct (Select all that apply): Select one or more: A....
Which of the following statements are correct (Select all that apply): Select one or more: A. An income statement reports on financing activities. B. A balance sheet reports on investing and financing activities. C. The statement of cash flows reports on cash flows from operating, investing, and financing activities over a period of time. D. A balance sheet reports on a company's assets and liabilities over a period of time. E. The statement of equity reports on changes in the...
Which of the following statements are correct (Select all that apply): Select one or more: A....
Which of the following statements are correct (Select all that apply): Select one or more: A. A balance sheet reports on investing and financing activities. B. An income statement reports on financing activities. C. The statement of equity reports on changes in the accounts that make up equity. D. The statement of cash flows reports on cash flows from operating, investing, and financing activities over a period of time. E. A balance sheet reports on a company's assets and liabilities...
Which of the following is / are not true about Securitization: - Select one: a. It...
Which of the following is / are not true about Securitization: - Select one: a. It is process by which receivables are converted into securities b. It is process by which collateral securities are given by borrowers to financial institutions for loan c. It is a process by which default risk is transferred to third parties d. It is a process in which SPV plays the vital role.
Which of the following items will not be reported on a balancesheet?Select one or...
Which of the following items will not be reported on a balance sheet?Select one or more:a. Current assetsb. Common Stockc. Total Liabilitiesd. Net IncomeI know D is not found on a balance sheet, but are there any others?
Which of the following is not an advantage of incorporation? Select one: a. There may be...
Which of the following is not an advantage of incorporation? Select one: a. There may be tax advantages b. Shareholders can veto decisions of directors. c. Shareholders owe no duty to the corporation. d. Shares are easily transferred. e. Shareholders are not liable for debts of the corporation. Which of the following is false with respect to methods of carrying on a business? Select one: a. A ‘society’ must be for a non-profit purpose. b. Unlimited liability means that an...
Which of the following is an example of an expense? Select one: a. the cost of...
Which of the following is an example of an expense? Select one: a. the cost of a proposed advertising campaign b. the cost of a product delivered to a customer c. the cost of the purchase of equipment d. the write-off of an obsolete product
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT