You can declare a void method as follow; public void int calculateSalary() { int num1=89; int num 2= 71; int sum= num1+num2; return sum; } a) True b) False
Q: The return statement of a void method may have one of two forms (assuming x is an int). to return x…
A: Introduction: Void methods don't produce any output because they are declared to be empty. A return…
Q: A void method may contain a return statement in which form (assume x is int)? o return x; o return…
A: option(C) is the correct option
Q: Identify the error(s) of the following method header: public static double method1(int num1,…
A: In java function we the parameter should have type defined. But in above public static double…
Q: Find out the output of the following code snippet? class OverloadingCalculation3{ void sum(int…
A: We are going to find out the output of given code snippet. Here, we are given a sum() function which…
Q: PART 2 Problem #2: [25 pts] Print Multiples a) Write a method printMultiples that takes two integers…
A: import java.util.Scanner; public class Main{ public static void printMultiplies(int x, int y){…
Q: A method named reverse that takes an integer and returns the reversal of the passed integer. The…
A: code : import java.util.Scanner;public class Main { /** Main Method */ public static void…
Q: public static boolean isPrime(int number) public static void printPrime(int x) - printPrime method…
A: Sample Output: 2 3 5 7 11 13 17 19 23 29 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73…
Q: A method may accept any number of values, including zero O True O False
A: True
Q: True or False? Arrays cannot be passed as parameters, but must be used only in the main method.
A: Array is a data type which contain similar data type values. In any programming language, the…
Q: Constructor : initialize all values to 0 getAsk() : Ask users to input two integer numbers. This…
A: 1- In this assignment require, ask three numbers from the user. 2- firstNumber, secondNumber, and…
Q: Question 1) Write a method that takes continuously a positive number from the user and then returns…
A: Here, Code instruction is given.
Q: What can we tell by the following method header: public static int nameReverse (String name) { } the…
A: Function
Q: Java language Write a method to find the number of hours, minutes, and seconds and then display it…
A: Let's understand the basics:- 1 hour = 60 minutes 1 minute = 60 seconds So, 1 hour = 60 minutes * 60…
Q: Financial Application:• Write a program that computes future investment value at a given interest…
A: Program plan:Import necessary packages.Define a class named “Investment”.Define a method named…
Q: 1. Examine the following method header; then write an example call to the method. private void…
A: A method is a block of code used to perform certain actions. A method is define once, and use…
Q: A(n) __________ is a special variable that receives an argument when a method is called. a.…
A: Explanation: If a method needs to receive arguments, then the method call should pass some…
Q: Toll roads have different fees based on the time of day and on weekends. Write a method calcToll()…
A: First we will convert both the time intervals given (i.e. Weekdays and Weekends) into minutes only.…
Q: What does the following statement represent (no semicolon or braces): public void myMethod() O…
A: A method is a block of code which only runs when it is called. You can pass data, known as…
Q: A method CAN be invoked using a variable that is initialized to null. O True False
A: Given that a method can be invoked by a variable that is initialized to null. True False Almost all…
Q: Predict the return type of the below method. public static _______ calculate(int a , double b) {…
A: The options “int”, “float”, and “boolean”, are not the correct answers as the given method doesn’t…
Q: One lap around a standard high-school running track is exactly 0.25 miles. Write a program that…
A: Required: One lap around a standard high-school running track is exactly 0.25 miles. Write a…
Q: (Number of days in a year) Write a method that returns the number of days in a year using the…
A: public class Solution { public static boolean isLeayYear(int y) { // if leap year…
Q: The following statement calls a method named ShowHalf. The ShowHalf method displays a value that is…
A: Algorithm to write the method: The given statement is used to call a method named "ShowHalf".…
Q: Write a program that will: First, add 2 double numbers void add1 (double n1, double n2)…
A: Programming instructions: Include necessary header files. In the main, create the Scanner object…
Q: Exercise 7.1 A friend of yours shows you the following method and explains that if number is any…
A: No, He is not Right. The Program is showing output "8". There is a little modification in this…
Q: Write a value-returning method isinRange. The method accepts 3 integer arguments: a number, a lower…
A: Code is given below step
Q: Task2. Write a method that returns a random number from a list of numbers passed in the argument.…
A: Given:
Q: The first method of the class will ask the user to input two numbers. Four methods will return their…
A: The question is to write java code for the given problem.
Q: List the name of this method and the name and type of its parameter:public void setCredits(int…
A: public void setCredits(int creditValue) { credits = creditValue;}
Q: e windChill method accepts the temperature and wind speed as whole numbers and returns the…
A: Here the function windChill is returning a whole number. So return datatype has to be int. The…
Q: A(n) __________ can have an uninitialized value passed into it, but it must be set to some value…
A: Answer is given below,
Q: Write a method called CaculateTuitionFee(int numberOfCourses, double costPerCourse = 449.99). This…
A: Coded using C#.
Q: Define the running time T(n) of the calculateSum method provided public static int…
A: let execution time for 1 statement is = 1 unit of time. Total (1 +1 + 4xn + 1) = (4n+3) statement…
Q: java-Find the area of circle using method... Write an application that prompts the user for the…
A: import java.util.*;public class Main { public static double circleArea(double r){ return…
Q: Financial Application:• Write a program that computes future investment value at a given interest…
A: Program plan:Import necessary packages.Define a class named “Main”.Define a method named…
Q: 1)What is the return type of a method that does not return any value? a) int b) float c) void d)…
A: 1. Answer: c Explanation: The function that does not return any value is termed as the void…
Q: Your program must define and call the following method. The method should return true if the input…
A: if multiple of 4 if multiple of 100 if multiple of 400…
Q: Select the header of a method that displays whether a character is a letter or a digit. * public…
A: Answer : -- option B) publi static void isVowel( char ch)
Q: Write a program to calculate area of circle. The main method should pass the radius of the circle to…
A: Algorithm : calculateArea function : Step 1 : declare variable. Step 2 : find the area using…
Q: /** * B. Complete a method named blackJack(). * The method is given 2 int values, both of which are…
A: public int blackjack(int a, int b) { int diffA, diffB; diffA = 21 - a; diffB = 21 - b;…
Q: What does the following method do? public int question15( ) { int value1 = 0; int value2 = 0;…
A: 3.It returns the index of the child who sold the most candy bars
Q: T/F 2) There is no base case in the following method. public int noBaseCase(int x) { if(x > 0)…
A: Given that, There is no base case in the following method. public int noBaseCase(int x){if(x >…
Q: 1. Complete the following methods: a) public static double calculateArea (double radius) { // return…
A: a) public static double calculateArea (double radius){ double area; area= 3.14*radius*radius; return…
You can declare a void method as follow;
public void int calculateSalary()
{
int num1=89;
int num 2= 71;
int sum= num1+num2;
return sum;
}
Step by step
Solved in 2 steps
- public static int cube(int num { return num num num; } What is the correct statement to pass value 8 to this method and assigns its return value to a variable named result? O cube(8) = int result; int result = cube(8) O int result = O int result = int cube(8);15) What does the following method do?public int question15( ) {int value1 = 0;int value2 = 0;for(int j=0; j<12; j++)if(candy[j] > value1){value1 = candy[j];value2 = j;}return value2;}List the name of this method and the name and type of its parameter:public void setCredits(int creditValue){ credits = creditValue;}
- mport java.util.Scanner; public class ParkingCharges { // function to calculate the basic charge using the asked hours static double getBasicCharge(int hours) { if (hours >= 7 && hours <= 8) return 5.50; else if (hours >= 5 && hours <= 6) return 4.50; else if (hours >= 2 && hours <= 4) return 4.00; return 3.00; } // function to return the amount to subtract based on local living and OAP static double getDiscount(String isLocal, String isOAP) { if (isOAP.equals("Yes") && isLocal.equals("Yes")) return 2.0 + 1.0; else if (isOAP.equals("Yes")) return 2.0; else if (isLocal.equals("Yes")) return 1.0; return 0; } public static void main(String[] args) { // create a new Scanner object Scanner sc = new Scanner(System.in); // prompt the user to ask if they are disabled…Free Response Question: 28. Write a method that will return true if a randomly generated number between 1 and 10 is less than or equal to 4. public static boolean FortyPercentOrLess() { }Use Java programming language Write a program that asks the user to enter 5 test grades (use an array to store them). Output the grades entered, the lowest and highest grade, the average grade, how many grades are above the average and how many are below and the letter grade for the average grade. Create a method that returns the lowest grade. Create a method that returns the highest grade. Create a method that returns the average grade. Create a method that returns how many grades were above the average. Create a method that returns how many grades were below the average. Create a method that returns the letter grade of the average (90-100 – A, 80-89 – B, 70-79 – C, < 70 – F)
- Use Java programming language Write a program that asks the user to enter 5 test grades (use an array to store them). Output the grades entered, the lowest and highest grade, the average grade, how many grades are above the average and how many are below and the letter grade for the average grade. Create a method that returns the lowest grade. Create a method that returns the highest grade. Create a method that returns the average grade. Create a method that returns how many grades were above the average. Create a method that returns how many grades were below the average. Create a method that returns the letter grade of the average (90-100 - A, 80-89 - B, 70-79 - C, < 70 - F)42) Look at the following method: public static int test2 (int x, int y) if (x < y) { return -5; } else { return (test2 (x - y, y + 5) + 6) ; } } What is returned for test2 (10, 20)? A) -5 B) 1 C) 6 D) 10 43) This term is used for methods that directly call themselves. A) Simple recursion C) Absolute recursion B) Direct recursion D) Native recursion 44) If the base case in a recursive method is never reached: A) The result will always be off by one. C) The method will call itself indefinitely. B) The method will call itself only once. D) The method will never call itself. 45) A(n) is an object that is generated in memory as the result of an error or an unexpected event. A) exception C) default exception handler B) exception handler D) error message 46) All of the exceptions that you will handle are instances of classes that extend this class. A) Exception C) IOException B) RunTimeException D) Error 47) All exceptions are instances of dasses that extend this class. A) Throwable C)…26. Assume the declaration of Exercise 24. A. Write the statements that derive the class dummyClass from class base as a private inheritance. (2 lines are { and }.) "A1 is { "A2 is "A3 is )) B. Determine which members of class base are private, protected, and public in class dummyClass. "B1 is dummyClass is a de
- Find the error of the following method definition: public static void timesTwo( int x, int y) { int sum=x + y; return sum; }A void method may contain a return statement in which form (assume x is int)? O return x; O return 10; return; return (x);The return statement of a void method may have one of two forms (assuming x is an int). to return x to return a tenth; to return