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
liraira [26]
3 years ago
12

Which of the following method signatures correctly specifies an array as a return type?

Computers and Technology
1 answer:
kow [346]3 years ago
4 0

Answer:

private int[ ] testMethod ( int x )

Explanation:

Before going to the reason first understand the syntax of declare the function.

Syntax:

Access_modifier return_type name (argument_1, argument_2,...);

Access_modifier is used for making the restriction to access the values.

it is public, private and protected.

Return_type:  it is used to define return type of the function.

it can be int, float, double.

In the question:

Option 1:  private array testMethod ( int x )

it is not valid because array is not valid return type.

Option 2: private int[ ] testMethod ( int x )

int[ ]  denotes the integer array. so, the function return the integer array.

Option 3: private double[5] testMethod ( int x )

it is not valid because double[5] is not valid return type. we cannot enter the size of the array.

if we replace double[5] to double[ ], then it valid and the function return double type array.

Option 4: private double testMethod[ ] ( int x )

it return type is double. So, it return the decimal value but not array.

Therefore, the correct option is (b).

You might be interested in
Instructions Write a program that allows the user to enter the last names of five candidates in a local election and the number
KengaRu [80]

Here is code in java.

import java.util.*;

class Election

{ //main method

   public static void main(String args[]){

      // create an object of Scanner class to read input

      Scanner s = new Scanner(System.in);

      // string array to store name of candidates

       String name[] = new String[5];

       // int array to store vote count of candidates

       int v_count[] = new int[5];

       double p = 0;

       int i = 0, sum = 0, high =0, win = 0;

for(i = 0; i < 5;i++)

       {

          System.out.print("last name of Candidate " + (i+1) + ":");

          // read name of Candidate

          name[i] = s.next();

          System.out.print(" number of votes received: ");

          // read vote of Candidate

           v_count[i] =s.nextInt();

if(v_count[i] > high)

              {

                  // highest vote

                  high = v_count[i];

                  win = i;

              }

              // total vote count

           sum +=v_count[i];

       }

     // printing the output

      System.out.println("\nCandidate\tVotes Received\t% of TotalVotes\n");

       for(i = 0; i < 5;i++)

       {

           // % of vote of each Candidate

           p =(v_count[i]*100)/sum;

           // print the output

          System.out.println(name[i] + "\t\t" + v_count[i] + "\t\t\t" +p);

       }

       // print the total votes

      System.out.println("\nTotal Votes:\t" + sum);

      // print the Winner of the Election

       System.out.println("Winner of the Election is: " + name[win]);

   }

}

Explanation:

Create a string array "name" to store the name of candidates.Create Integer array "v_count" to store votes os each candidates.Calculate total votes of all candidates and find the highest vote amongst all candidate and print it.Find % of votes received by each candidate.Print these stats.

Output:

last name of Candidate 1:patel

number of votes received: 54

last name of Candidate 2:singh

number of votes received: 76

last name of Candidate 3:roy

number of votes received: 33

last name of Candidate 4:yadav

number of votes received: 98

last name of Candidate 5:sharma

number of votes received: 50

Candidate       Votes Received  % of TotalVotes

patel           54                      17.0

singh           76                      24.0

roy             33                      10.0

yadav           98                      31.0

sharma          50                      16.0

Total Votes:  311

Winner of the Election is: yadav

8 0
3 years ago
Investigate the many ways that hardware and software can cause an interrupt to occur. Are ALL interrupts treated equally or do s
slavikrds [6]

Answer:

Following are the responses to the given question:  

Explanation:

This list is based mostly on the processor. Then you'll be ordered. An interrupt of a particular cable (wire) is produced for PC-ish CPUs (IRQ 0 - 31 for some intel processors). The bigger challenge is a lower number.

Strange factors have included a system clock, power business, 0, some reserved for use by CPU testing, serial/parallel/... ports and also some terminated/error/state/new devices requests device Thus a key touch on the keyboards could create an interrupt that was direct on old devices.

3 0
2 years ago
What is co-operating process
Greeley [361]

Answer: A process is independent if it cannot affect other process or be affected by it

Explanation:

3 0
3 years ago
What special case exists when managing linked lists?
tiny-mole [99]

Explanation:

The special case that exists in linked list when we are managing them is when we are dealing with the first element of the list.

When we create a linked list we create a first node separately.

If we delete or add element in front of the first element we have to carefully handle that case.

Hence the special case is when we are dealing with the first element of the list.

6 0
2 years ago
Performance testing is only important for real-time or embedded systems. <br> A) TRUE<br> B) FALSE
blagie [28]
The answer is B) False
8 0
3 years ago
Other questions:
  • You are an administrator for contoso.com. you have two servers called server1 and server2 that run windows server 2012 and have
    9·1 answer
  • Why might a government entity choose to offer some information and services online as in e-government
    8·2 answers
  • When two or more tables share the same number of columns, and when their corresponding columns share the same or compatible doma
    12·1 answer
  • _____ include the people, procedures, hardware, software, data, and knowledge needed to develop computer systems and machines th
    11·1 answer
  • Elizabeth works for a local restaurant at the end of her shift she read she’s required to write in the time that she arrived in
    14·1 answer
  • . Which of the following is NOT a valid declaration for a character string?
    6·1 answer
  • The Brinley website will not let me search for questions anymore. It says “Search all you want in-app” and then covers the quest
    14·1 answer
  • Queues can be represented using linear arrays and have the variable REAR that point to the position from where insertions can be
    12·1 answer
  • Need Help Please
    7·1 answer
  • Which LIKE operator would match a single character?<br><br> *<br> ?<br> []<br> #
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!