Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Assume that the following declaration has been made: Which of the following

ID: 657927 • Letter: J

Question

Java

Assume that the following declaration has been made: Which of the following statement or statements are true after the execution of the above declaration? Circle the correct answer(s) Write statements necessary to switch the first and the last array element. What is wrong with the following statement? Use the following description to answer (b) and (c). Here is a simplified class student for representing students at Victoria University. Each Student object has a name, id, address and course code. Suppose we have a class named StudentDB to manage an ArrayList collection of students known as myStudents. Below is a partial listing of the class. Define the search method. //Write your search (String anID) method here Define the changeCourse method. //Write your changeCourse (String anID, String newCourse) method here

Explanation / Answer

Answer:-

i)

a) False; because number[1]=45

b) True;

c) False; number[6] element is not present,there must only nummber[5] elements present.

d) True; number.length is 6.

e)False; because number[0]=23

ii)

public static void main(String[] args)

{

   int[] array = new int[10];

   int length = array.length;

    for (int k = 0; k< length; k++)

    {

        array[k] = (int)(Math.random () * 6);

        System.out.print(array[k]);

    }

    System.out.println("");

    switchFirstAndLast(array);

    replaceEvenWithZero(array);

}

public static void switchFirstAndLast(int[] array)

{

    int k = array[0];

    int n = array[array.length - 1];

     int hold = array[k];

     array[k] = array[n] ;

     array[n] = hold;

     for (int l = 0; l < 5; l++)

      {

         System.out.print(array[l]);

      }

     System.out.println("");

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote