1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Advocard [28]
3 years ago
8

What does the following code print?double[] myList = {1, 5, 5, 5, 5, 1};double max = myList[0];int indexOfMax = 0;for (int i = 1

; i < myList.length; i++) { if (myList[i] >= max) { max = myList[i]; indexOfMax = i; }}System.out.println(indexOfMax);
Computers and Technology
1 answer:
Liula [17]3 years ago
7 0

Answer:

This code will print: 4

Explanation:

Following is the step-by-step explanation for the given code:

  • Given is the array of data type double named myList, it has entries, 1, 5, 5, 5,5, 1:

                    double[] myList = {1, 5, 5, 5, 5, 1};

  • Now the first element of the array (1) with index 0 will be stored in the variable max (data type double).

                 double max = myList[0];  

  • A variable indexOfMax having datatype int will be initiated as 0.

                 int indexOfMax = 0;

  • Now for loop will be used to find the maximum number of the array. The variable i will be put as index for each element to compare with first element. If the checked element is greater than or equal to the integer in max, it will be replaced. So at the end the variable max will have value 5 that will be at index i = 4.

                    for (int i = 1; i < myList.length; i++)

                            { if (myList[i] >= max)

                               { max = myList[i];

  • Now the variable i that is the index for max value will be stored in the variable indexOfMax (indexOfMax = 4).

                  indexOfMax = i; }}

  • At end the value stored in variable indexOfMax will be printed, so 4 will be printed as output.

              System.out.println(indexOfMax);

i hope it will help you!

You might be interested in
Consider the following code: public static void mystery(int a) { System.out.println("A"); } public static void mystery(double a)
Feliz [49]

Answer:

The output is "A"

Explanation:

public class Solution {

   public static void main(String args[]) {

     mystery(7);

   }    

   public static void mystery(int a) { System.out.println("A"); }    

   public static void mystery(double a) { System.out.println("B"); }    

   public static void mystery(int a, double b) { System.out.println("C"); }    

   public static void mystery(double a, int b) { System.out.println("D"); }

}

In the code above; mystery is defined in four different ways called method overloading. Method overloading is when same method is defined with different parameters.

In the first case; mystery will be called if the argument is int.

In the second case; mystery will be called if the argument is double.

In the third case; mystery will be called if the arguments are int and double.

In the fourth case; mystery will be called if the arguments are double and int.

When mystery(7) is called; the mystery method requiring only int will be called and the output is "A".

3 0
4 years ago
You want to plug a keyboard into the back of a computer. you know that you need to plug the keyboard cable into a ps/2 port. whi
Helga [31]

<span>Often referred to as the mouse port or keyboard port, the PS/2 port was developed by </span><span>IBM and is used to connect a computer mouse or keyboard to an IBM compatible computer. <span>Its name originates from the IBM Personal System/2 arrangement of PCs, with which it was propelled in 1987.</span></span>

7 0
3 years ago
Which of the following software is cloud-based? OpenOffice Writer Word 2013 Word Online Word Perfect\
evablogger [386]
I think its open office
3 0
3 years ago
Read 2 more answers
What are the different components of the cloud architecture? The of the cloud architecture is the cloud, which is a collection o
tester [92]

Answer:

Cloud Architecture is basically consist of front end platform, back end platform, cloud and a network.

Explanation:

Front end platform consists of client and mobile device. while Back end platform consist of server and storage. The Cloud is the collection of data and Network is consist of Intranet and internet.

All the above mentioned components combined together to complete the architecture of cloud.

3 0
3 years ago
A ___ is an online collaborative event that may include such features as chat, slideshows, and PowerPoint presentations.
german

Answer:

I think Microsoft Teams

Explanation:

Microsoft Teams. Teams is a chat-based collaboration tool that provides global, remote, and dispersed teams with the ability to work together and share information via a common space. You can utilize cool features like document collaboration, one-on-one chat, team chat, and more. Microsoft Teams is also fully integrated with many other Office 365 services, such as Skype, SharePoint, Exchange, and Yammer.

5 0
3 years ago
Other questions:
  • Using a second hash function to compute increments for probe increments is called
    15·1 answer
  • T<br> F<br> 5.<br> You can save presentations in PDF and XPS formats.
    14·1 answer
  • A primary mailing list for new vulnerabilities, called simply __________, provides time-sensitive coverage of emerging vulnerabi
    10·1 answer
  • Which activity does not allow a person to perform any work while at the shop
    10·1 answer
  • You have a notebook computer and wish to connect to an IEEE 802.11ac wireless network. The computer does not have a built-in WLA
    15·1 answer
  • Please someone helpp
    12·2 answers
  • Anyone follows abhay​
    10·1 answer
  • What is DMTS. Explain it​
    10·2 answers
  • They removed my other post but I didn't learn my lesson :)
    11·1 answer
  • If we are transferring data from a mobile device to a desktop and receive an error message that the mobile device has stopped co
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!