Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Big Java Late Objects
Quiz 5: Methods
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 21
Multiple Choice
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?
Question 22
Multiple Choice
Consider a method named calc, which accepts two numbers as integers and returns their sum as an integer. Which of the following is the correct statement to invoke the method calc?
Question 23
Multiple Choice
What is the output of the following code snippet? Public static int recurrAverage(int num) { Int sum = 0; For (int x = 1; x <= num; x++) { Sum = sum + x; } Return sum / num; } Public static void main(String[] args) { System.out.println(recurrAverage(recurrAverage(16) ) ) ; }
Question 24
Multiple Choice
What is the error in the following method definition? public static int tripler(int numPara) { double result = numPara * 3; }
Question 25
Multiple Choice
Consider this method comment. Which of the following options is recommended in your textbook? /** Computes the area of a cuboid. @param width the width of the cuboid @return the area of the cuboid */ Public static double area(double width, double height, Double length) { Double result = width * height * length; Return result; }
Question 26
Multiple Choice
What is the syntax error in the following method definition? Public static String parameter(double r) { Double result; Result = 2 * 3.14 * r; Return result; }
Question 27
Multiple Choice
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?
Question 28
Multiple Choice
What is the error in the following method definition? Public static void findMin(int x, int y) { Int min = 0; If (x < y) { Min = x; } Else { Min = y; } }
Question 29
Multiple Choice
The Java method Math.round can be used to round numbers. Which of the following code fragments converts a floating-point number to the nearest integer?
Question 30
Multiple Choice
In an accounting application, you discover several places where the total profit, a double value, is calculated. Which of the following should be done to improve the program design? I. The next time the total profit is calculated, use copy and paste to avoid making coding errors. II. Provide the same comment every time you repeat the total profit calculation. III. Consider writing a method that returns the total profit as a double value.
Question 31
Multiple Choice
What is the output of the following code snippet? Public static void doubleAmount(int intvalue) { Intvalue = 2 * intvalue; } Public static void main(String[] args) { Int principalAmt = 2000; System.out.println(doubleAmount(principalAmt) ) ; }