17. What is the problem with the definition of the following method that calcula
ID: 3680054 • Letter: 1
Question
17.
What is the problem with the definition of the following method that calculates and returns the tax due on a purchase amount?
Select one:
a. The taxDue method should not be static.
b. The data type of the parameter variables is incorrect.
c. The taxDue calculation is incorrect.
d. The taxDue method does not return a value.
18.
Which of the following options represents the output of the given code snippet?
Select one:
a. Sub 5 = 6, Add 6 = 6
b. Sub 5 = 4, Add 6 = 7
c. Sub 5 = 6, Add 6 = 5
d. Sub 5 = 4, Add 6 = 6
19.
Consider a method named avg, which accepts four numbers as integers and returns their average as a double. Which of the following is a correct call to the method avg?
Select one:
a. avg(2, 3.14, 3, 5);
b. double average = avg(2, 3, 4, 5);
c. avg();
d. double average = avg("2", "3", "4", "5");
20.
Given the method below, what is the output of the method call is div(10)?
Select one:
a. 0 10
b. 3
c. 0 3
d. 10
21.
Given the code below, what is the output of the method call hashIt("#", 6)?
Select one:
a. 0#///2#//4#/6
b. 0#/2#//4#///6
c. 0/2#//4#///6#
d. #/6#//4#///20
22.
What is the output of the following Java program?
Select one:
a. -1 0 1 4
b. 1 0 1 4
c. -1 0 1 4 9
d. 1 4 9 16
23.
he variable name perfect in the method myFun in the code snippet below is used as both a parameter variable and a variable in a nested block within the method. Which statement about this situation is true?
Select one:
a. This multiple declaration of the variable perfect will not compile because the scopes overlap
b. While this is legal and will compile in Java, it is confusing
c. Because the scopes of these variables do not overlap, there is no problem
d. This situation rarely occurs and the compiler always issues a warning
Explanation / Answer
Answers are given below:
Question 17:
d. The taxDue method does not return a value.
Question 18:
c. Sub 5 = 6, Add 6 = 5
Question 19:
b. double average = avg(2, 3, 4, 5);
Question 20:
c. 0 3
Question 21:
a. 0#///2#//4#/6
Question 22:
b. 1 0 1 4
Question 23:
a. This multiple declaration of the variable perfect will not compile because the scopes overlap
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.