Suppose you have a problem where you trying find the smallest integer in an arra
ID: 3805557 • Letter: S
Question
Suppose you have a problem where you trying find the smallest integer in an array of integers. Which of the following Java programming concepts would be the best fit use to solve this problem? a while loop b if - else branching c. integer division rules d. the remainder operator (i.e. a % b) 5. Which of the following method headers are examples of functions? (Mark ALL that apply) a. private static void mystery (int x) b. private static string mystery () c. private static void mystery () d. private static int mystery (string x) e. None of the above are examples of functions 6. If x y and z are boolean variables, for what values of x, y and z does the expression ((!x II y) && z) evaluate to false? (Mark ALL that apply) a. x = false, y = true z = false b. x = true, y = false z = false c. x = false y = true z = true d. x = true. y = true z = true e. The expression can be false, but not for any of the assign values listed above f. The expression cannot be false, no matter how you assigned values to x, y and z f 7. If i, j and k are int variables, for what values of I, j and k does the expression (((i = =j) II (i> = k)) && (j % k = = 0) evaluate to true? (Mark ALL that apply) a. i = 8, j = 9, k = 2 b. i = 5, j = 15, k = 5 c. i = 6, j = 6, k = 3 d. i = 11, j = 20, k = 20 e. None of the above assignments of i j and k make the expression trueExplanation / Answer
Solution:
4. Ans : a
While loop is the best fit to find the smallest integer in an array of integers. We compare first 2 integers and store the smaller one in a temporary variable. Then navigate to the next pointer and compare the value of temporary variable with the next integer and store the smaller one in the temporary variable. In this way, we can compare the entire array elements one by one in a while loop to find out the smallest integer in an array.
5 .Ans: b & d
There are 3 kinds of methods in Java.
i) Procedure
ii) Function
iii) Constructor
Among them, Function is an expression which should return a value. Among the given 4 options, option a & c method headers return type is void. So those 2 headers are Procedures. While option b & d method headers return type is string and int respectively. So those 2 headers are examples of Functions.
6. Ans: a & b
Given Expression : ((! X II Y) && Z)
Results :
7. Ans: b & c
Given Expression : ( ( ( i == j) || ( i >= k) ) && ( j % k ==0) )
Results :
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.