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
ivanzaharov [21]
3 years ago
6

What is the problem with the code snippet below? public class Test { public static void main(String[] args) { System.out.println

(cost(10, 4)); } public static void cost(int price, int reps) { for (int i = 0; i < reps; i++) { System.out.print(price); } } }
Computers and Technology
1 answer:
FrozenT [24]3 years ago
6 0

Answer:

The problem in the following snippet is that the function "cost" returns the void and it cannot used as the expression in the print statement

Explanation:

public class Test

{

    public static void main(String[] args)

    {

          System.out.println(cost(10, 4));

     }

     public static void cost(int price, int reps)

     {

           for (int i = 0; i < reps; i++)  

           {

                   System.out.print(price);                

           }  

     }

}

Output:

Main.java:4: error: 'void' type not allowed here

        System.out.println(cost(10, 4));

                               ^

1 error

In the following code the void type is not allowed in the function "cost".

You might be interested in
Contemporary operation of networking technology is possible only through the usage of open-use technology and layering approache
eimsori [14]

Answer: TRUE

Explanation: Networking technology is the term used to describe the entire processes through which computer or mobile systems are linked up either through optic fibers,wireless systems in order to enhance effective communication across networks or regions.

OSI (open system interconnection), the earliest models partitions into seven layers and the OSI is known as model that creates partitioning a communication system classing them into abstraction layers.

8 0
3 years ago
are designed to locate information based on the nature and meaning of Web content, not simple keyword matches Select one: a. Cra
san4es73 [151]

Answer: C. Semantic Search Engines

Explanation:

Semantic search is simply search with meaning. It is designed to locate information based on the nature and meaning of Web content, not simple keyword matches (like in lexical searches)

4 0
3 years ago
What is web browser <br>​
xeze [42]
An application used to access and view websites
7 0
3 years ago
Read 2 more answers
Which can be used to plan a program?
Marina86 [1]

Answer:

Pseudocode.

Hope this helps you...

Explanation:

8 0
3 years ago
Read 2 more answers
To remove any hidden data from your document before sharing it, what should you do?
almond37 [142]
B. becasue the repeation of a b and c i assume its not d, for that could be too easy it says REMOVE so that being the key word i ruled out A and C
4 0
3 years ago
Other questions:
  • Abigail is interested in connecting her tablet that usually connects to a wireless network, to her personal computer that usuall
    11·2 answers
  • Describe Mr. Digby, the principal. ​
    10·1 answer
  • Typically, a dvd has how many times more capacity than a cd?
    5·1 answer
  • Most Internet users access commercial websites, which have higher-quality information because of higher editing standards and th
    12·1 answer
  • IT professionals should help to protect users’ personal information, such as bank account information or Social Security numbers
    14·1 answer
  • Why might reading a product review be a good idea before purchasing a product?
    5·2 answers
  • What channel does the news come on? <br><br> i dont have cable i have roku :\
    8·1 answer
  • What<br>are<br>the features of secondary storage media​
    13·2 answers
  • Which of the following is an example of phishing attack? csp
    8·1 answer
  • A new thread begins its life cycle by transitioning to the ________ state. Group of answer choices new runnable waiting terminat
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!