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
Hoochie [10]
3 years ago
6

Which of the following would be a valid method call for the following method? public static void showProduct (int num1, double n

um2) { int product; product = num1 * (int)num2; System.out.println("The product is " + product); }
Computers and Technology
1 answer:
Alenkinab [10]3 years ago
3 0

Answer:

showProduct(int,double)

for example: showProduct(10,10.5) is the correct answer even showProduct(10,10.0) is also correct but showProduct(10.0,10.5) or showProduct(10,10) or showProduct(10.0,10) are wrong calls.

Explanation:

The code is

  1.       <em>public static void showProduct (int num1, double num2){</em>
  2. <em>       int product;</em>
  3. <em>       product = num1*(int)num2;</em>
  4. <em>       System.out.println("The product is "+product);</em>
  5. <em>       }</em>

showProduct is function which asks for two arguments whenever it is called, first one is integer and second one is of type double which is nothing but decimal point numbers. Generally, in programming languages, 10 is treated as integer but 10.0 is treated as decimal point number, but in real life they are same.

If showProduct( 10,10.0) is called the output will be 'The product is 100'.

Strange fact is that, if you enter showProduct(10,10.5) the output will remain same as 'The product is 100'. This happens because in the 3rd line of code,which is <em>product=num1*(int)num2</em>, (int) is placed before num2 which makes num2 as of type integer, which means whatever the value of num2 two is given, numbers after decimal is erased and only the integer part is used there.

This is necessary in JAVA and many other programming languages as you <u>cannot</u><u> multiply two different datatypes</u> (here one is int and another is double). Either both of them should be of type int or both should be of type double.

You might be interested in
What Is the Purpose of a Web Browser? *<br><br>​
Aneli [31]
A web browser takes you anywhere on the internet. It retrieves information from other parts of the web and displays it on your desktop or mobile device. The information is transferred using the Hypertext Transfer Protocol, which defines how text, images and video are transmitted on the web.
6 0
2 years ago
Read 2 more answers
You wish to lift a 12,000 lb stone by a vertical
Shkiper50 [21]
Ndnsnskiaqosikejwnw sorry
3 0
3 years ago
What type of culture is computer hardware?
skad [1K]
Culture, the software, is learned to trigger evolution to a new type of society, they may all.
6 0
3 years ago
Read 2 more answers
When creating a presentation in Libre Office Impress, where does the editing of slides take place?
kondor19780726 [428]
The Canterbury Tales, written towards the end of the fourteenth century by Geoffrey Chaucer, is considered an estates satire because it effectively criticizes, even to the point of parody, the main social classes of the time. These classes were referred to as the three estates, the church, the nobility, and the peasantry, which for a long time represented the majority of the population.
4 0
3 years ago
Rows are typically represented by _______ and contain data for individual records
Agata [3.3K]
Records, data and tables are terns used in database software.Rows are typically presented by numbers and contain data for individual records. Records are used in database software to organize data. They are stored in tables.
4 0
3 years ago
Other questions:
  • Is bit stuffing necessary in the control or address field in theHDLC protocol? why?
    13·1 answer
  • What does limited access to a document mean?
    14·2 answers
  • Host to IP address lookup and its reverse lookup option are very important network services for any size network. It is also how
    14·1 answer
  • By placing the chorale melody in the highest voice and using a simple harmonization, bach made it easier for congregation member
    5·1 answer
  • The page orientation in which the page width is greater than the page height is called
    8·1 answer
  • Match the elements of a web page with their descriptions?
    15·2 answers
  • What should be done if a system cannot boot from the hard drive?
    14·1 answer
  • PLEASE HELP!!!!
    6·2 answers
  • Write a Racket two-way selection structure that will produce a list '(1 2 3) when the first element of a list named a_lst is ide
    13·1 answer
  • Define a function that will return the length of a list
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!