1. What is the output of the following code snippet? Select one: a. b = 100, c =
ID: 3680049 • Letter: 1
Question
1.
What is the output of the following code snippet?
Select one:
a. b = 100, c = 101
b. b = 99, c = 101
c. b = 0, c = 100
d. b = 0, c = 101
2.
Which of the following is true about methods?
Select one:
a. Methods can have only one argument and can return only one return value.
b. Methods can have multiple arguments and can return multiple return values.
c. Methods can have multiple arguments and can return one return value.
d. Methods can have one argument and can return multiple return values.
3.
In a vehicle mileage application, you enter number of miles traveled by a vehicle and the amount of fuel used for 30 consecutive days. From this data the average monthly mileage of the vehicle is calculated. Which of the following should be done to improve the program design?
Select one:
a. The next time the average monthly mileage is calculated, use copy and paste to avoid making coding errors.
b. Provide the same comment every time you repeat the average monthly mileage calculation.
c. Consider writing a method that returns the average monthly mileage as a double value.
d. Consider writing a method that returns void
4.
Which of the following code snippets returns the factorial of a given number? (Hint: Factorial of 5 = 5! = 1 * 2 * 3 * 4 * 5 = 120)
Select one:
a.
b.
c.
d.
5.
What are the values of x and y after executing the code snippet below?
Select one:
a. x = 10 and y = 11
b. x = 11 and y = 10
c. x = 0 and y = 0
d. x = 11 and y = 11
Explanation / Answer
Answers are given below
Question:1
c. b = 0, c = 100
Question:2
c. Methods can have multiple arguments and can return one return value.
Question:3
c. Consider writing a method that returns the average monthly mileage as a double value.
Question:4
d.
public static int factorial(int num)
{
if (num == 1)
{
return 1;
}
return num * factorial(num - 1);
}
Question:5
a. x = 10 and y = 11
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.