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

Answer all questions for thumbs up rating, no coding required, just multiple cho

ID: 3771182 • Letter: A

Question

Answer all questions for thumbs up rating, no coding required, just multiple choice:


Question 16 of 30     (worth 3 points)

Pick all that apply:

java.util.Arrays class contains which of the following methods?

Check to review before finishing (will be flagged in Table of Contents)

Question 18 of 30     (worth 3 points)

Consider the following class:

public class Bicycle {

    private int cadence;
    private int gear;
    private int speed;
    private int id;
    private static int numberOfBicycles = 0;

    public Bicycle(int startCadence, int startSpeed, int startGear){
        gear = startGear;
        cadence = startCadence;
        speed = startSpeed;

       id = ++numberOfBicycles;
    }

  
    public int getVar() {
        //TODO return a variable
    }
    

    public static int getVariable() {
        //TODO return a variable
    }

}

Which of the following return statements should be used in the getVar and getVariable methods?

public static int getVariable() {
        return numberOfBicycles && id;
    }

public static int getVariable() {
        return id;
    }

public static int getVariable() {
        return id;
    }

public static int getVariable() {
        return numberOfBicycles;
    }

Question 23 of 30     (worth 3 points)

The JButton class provides the functionality for an ordinary push button. A button can only contain text.

True
False

Check to review before finishing (will be flagged in Table of Contents)

Question 24 of 30     (worth 3 points)

Unlike radio buttons, in which many or none can be selected at once, check boxes only have one button selected at a time.

True
False

Check to review before finishing (will be flagged in Table of Contents)

Question 27 of 30     (worth 5 points)

Pick all that apply

Consider the following search method.

private static int search (int[] a, int target, int left, int right) {
   if (left > right)
      return 1?
   else {
   int midpoint = (left + right) / 2?
   if (a[midpoint] == target)
      return midpoint?
   else if (a[midpoint] < target)
      return search (a, target, midpoint + 1, right)?
   else
      return search (a, target, left, midpoint – 1)?
   }
}

Which of the following might be described as the base case(s) for this method to end the recursion?

if (a[midpoint] < target)

if (a[midpoint] > target)

if (a[midpoint] == target)

if (left > right)

Check to review before finishing (will be flagged in Table of Contents)

Question 29 of 30     (worth 5 points)

Pick all that apply:

Consider the following class:

private class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent evt)
    {
     String cmd = evt.getActionCommand();
     if (cmd.equals("Find"))
      
        //Find player
        String newName = Integer.toString(player.getValue(jtfName.getText()));
      
        jtfHighScore.setText(newName);
        jbtReplace.setVisible(true);
    
    
     else (cmd.equals("Replace"))
     {
       
        //Find player
      
        int newScore = Integer.parseInt(jtfHighScore.getText());
                 
        player.replaceVal(jtfName.getText(),
                            newScore);
        String topScores= player.showAll();
         jtxtTop.setText(topScores);
       
          jtfName.setText("");
          jtfHighScore.setText("");
   
     }
     else (cmd.equals("Add"))
      {
         
          //addressBook player = new addressBook();
          int newScore = Integer.parseInt(jtfHighScore.getText());
          player.add(jtfName.getText(), newScore);
        
          jtfName.setText("");
          jtfHighScore.setText("");
        
        
         String topScores= player.showAll();
         jtxtTop.setText(topScores);  

        }

   }

Itentify two major problems with this code.

int newScore = Integer.parseInt(jtfHighScore.getText());

else (cmd.equals("Replace"))

else (cmd.equals("Add"))

String topScores

if (cmd.equals("Find"))

Check to review before finishing (will be flagged in Table of Contents)

A. public static int binarySearch(Object[] a, Object key) B. public static void fill(int[] a, int val) C. public static boolean equals(long[] a, long[] a2) D. public static void sort(Object[] a)

Explanation / Answer

16)A,B,C,D

18)D

23)FALSE

24)FALSE

27)C,D

29)B,C

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