Question

1) double d1 = 2.5; double d2 = 4.5; double res = 0; res = (int)...

1)

double d1 = 2.5;
double d2 = 4.5;
double res = 0;
res = (int) (d1 + d2);
What will be stored in res?

 A. 7 B. 6 C. There will be an error because res is a double number

2)

If an array is of size N, then it has positions that range....

 A. from 0 to (N-1) B. from 1 to N C. from 0 to N D. from 1 to (N-1)

3)

Having more than one method with the same name but with different parameters is:

 A. not allowed in Java B. part of the Java's import procedure C. called method overload D. Is called method nesting

```1)
The value of res will be 7
A. 7

2)
If an array is of size N, then it has positions that range from 0 to (N-1)
A. from 0 to (N-1)

3)
Having more than one method with the same name but with different parameters is called method overload
```

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
• Array manipulation (a) Write Java code for a method exchange (int [] a, int i, int...

Array manipulation (a) Write Java code for a method exchange (int [] a, int i, int j) that exchanges the values stored at indices i and j in the array a. You do not need to worry about cases where either i or j is an invalid index. Give the best estimate you can for its time complexity (b) In an ordered array of n items, how can we determine whether or not an item belongs to the list using...

• (a) Write a program in Java to implement a recursive search function int terSearch(int A[], int...

(a) Write a program in Java to implement a recursive search function int terSearch(int A[], int l, int r, int x) that returns the location of x in a given sorted array of n integers A if x is present, otherwise -1. The terSearch search function, unlike the binary search, must consider two dividing points int d1 = l + (r - l)/3 int d2 = d1 + (r - l)/3 For the first call of your recursive search function...

• • bool test(int a, int& b) { bool res = false; if(a > b) { b...

• bool test(int a, int& b) { bool res = false; if(a > b) { b = a%2; res = true; } return res; } int main() { int x = 45, y = 43; test(x, y); cout << x << " " << y << endl; return 0; } Question: The output of the above code is: ________________ •Write a function that takes an integer as its sole parameter and returns -1, 0 or 1 depending upon whether the...

• TestScores . SIZE: int //size of the array scores: int [ 1 estScores findMax ( )...

TestScores . SIZE: int //size of the array scores: int [ 1 estScores findMax ( ) : int findMin ) int findScore (value: int): bool res(): int Write the constructor method. It fills the array with random number from 0-100. Find below the code to get your started 1. public TestScores () Random rand -new Random); for (int i-0 i<SIZE i+) socresi] -rand.nextInt (101); Finding the maximum value in an array. Write the method findMax. It returns the maximum value...

• A method called linearSearch(), which takes as parameters an array of int followed by three values...

A method called linearSearch(), which takes as parameters an array of int followed by three values of type int, and returns a value of type int. The first int parameter represents a key, the second int parameter represents a starting position, and the third int parameter represents an end position. If the key occurs in the array between the start position (inclusive) and the end position (exclusive), the method returns the position of the first occurrence of the key in...

• Question 1 In the following incomplete C program: #include stdlib.h> #include <stdio.h> int main () { int i, n, max; int array[100]; ... } return 0; } an array of random int values is populat...

Question 1 In the following incomplete C program: #include stdlib.h> #include <stdio.h> int main () { int i, n, max; int array[100]; ... } return 0; } an array of random int values is populated with n random values. Write only the code to find the location of the maximum value in the array. Question 2 Follow these instructions in your Linux account: 1. Create a file called data.txt in the root folder in your account. 2. Create a new...

• The loop below stores the values 1 to 5 in myList: for (int i = 0;...

The loop below stores the values 1 to 5 in myList: for (int i = 0; i < 5; i ++) { myList [ i ] = i + 1; //store values using a loop } The loop below prints the values from first to last in myList: for (int i = 0; i < myList.length; i++) { System.out.print(myList [ i ] + " "); } Use the examples on the slides to complete the lab below. Please submit the...

• Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array...

Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...

• Java deleting from an array // arrayDelete        //        // delete the value...

Java deleting from an array // arrayDelete        //        // delete the value in the array at position k        // positions are numbered starting with 0        // elements k+1 through N-1 are moved 'down' one position        // to close the space left by deleting element k        // set element N-1 to -99        // preconditions: 0 <= k <= N-1        //    public static void arrayDelete(...

Java please answer A to I please dont type the answer on paper please use the computer A.   Explain why alpha cannot be accessed by other members of its class. B.   In the program, how can you determine the type of access modifier? C.   Describe the differences and similarities of beta and gamma in program, within the context of access specifiers and class member accessibility. D.   Explain how objects, a and b, are passed to the method. E.    Why...