Question

In: Computer Science

Given the following method declaration, write a valid method call. public static void calcArea(String roomName, int...

Given the following method declaration, write a valid method call.


public static void calcArea(String roomName, int length, int width)

Solutions

Expert Solution

CLASSNAME.calcArea("Conference Room",100,200)

Explanation:

Static method should be called as CLASSNAME.METHODNAME

roomName is of type string: so we should pass string when calling this function.

length is of type int so we should pass an integer when calling this function.

width is of type int so we should pass an integer when calling this function.

Sample Program:

public class Main
{
public static void calcArea(String roomName, int length, int width)
{
System.out.println("Area of "+roomName+" = "+(length*width));
}
  
   public static void main(String[] args)
   {
Main.calcArea("Conference Room",100,200);
   }
}


Related Solutions

JAVA Given the header of a method public static void m1 (int[ ] max) Write down...
JAVA Given the header of a method public static void m1 (int[ ] max) Write down Java codes to invoke m1 method, declare variables as needed, (Do NOT implement the method)
public class Main { public static void main(String [] args) { int [] array1 = {5,...
public class Main { public static void main(String [] args) { int [] array1 = {5, 8, 34, 7, 2, 46, 53, 12, 24, 65}; int numElements = 10; System.out.println("Part 1"); // Part 1 // Enter the statement to print the numbers in index 5 and index 8 // put a space in between the two numbers and a new line at the end // Enter the statement to print the numbers 8 and 53 from the array above //...
---------------------------------------------------------------------------- public class Main { public static void main(String[] args) { int[] A = {11, 12,...
---------------------------------------------------------------------------- public class Main { public static void main(String[] args) { int[] A = {11, 12, -10, 13, 9, 12, 14, 15, -20, 0}; System.out.println("The maximum is "+Max(A)); System.out.println("The summation is "+Sum(A)); } static int Max(int[] A) { int max = A[0]; for (int i = 1; i < A.length; i++) { if (A[i] > max) { max = A[i]; } } return max; } static int Sum(int[] B){ int sum = 0; for(int i = 0; i --------------------------------------------------------------------------------------------------------------------------- Convert...
Write a method public static void minMax(int[] arr) that takes an array of unique ints of...
Write a method public static void minMax(int[] arr) that takes an array of unique ints of length at least two as an argument, and swaps the smallest value of the array into the 0th position and swaps the largest value of the array into the last position. For example, if int[] a = {4, 3, 2, 6, 1, 5}, the method call minMax(a) should modify the array so that it is {1, 3, 2, 5, 4, 6}. The method should...
class Main { public static void main(String[] args) {        int[] array = {1,2,3,4,5};   ...
class Main { public static void main(String[] args) {        int[] array = {1,2,3,4,5};        //Complexity Analysis //Instructions: Print the time complexity of method Q1_3 with respect to n=Size of input array. For example, if the complexity of the //algorithm is Big O nlogn, add the following code where specified: System.out.println("O(nlogn)"); //TODO }    public static void Q1_3(int[] array){ int count = 0; for(int i = 0; i < array.length; i++){ for(int j = i; j < array.length;...
Given the following TestDriver.java public class TestDriver {       public static void main(String args[]) {             Point point...
Given the following TestDriver.java public class TestDriver {       public static void main(String args[]) {             Point point = new Point(10, 5);       Circle circle = new Circle(10.5, 20, 19);       Cylinder cylinder = new Cylinder(12, 3.6, 20, 20);                     System.out.println("Point");       System.out.println(point.toString()) ;       System.out.println("Circle");       System.out.println(circle.toString());       System.out.println("Cylinder");       System.out.println(cylinder.toString());       } } You will get the following result once you execute the TestDriver.java (after compiling it) Point (10, 5) Circle Center = (20, 19); Radius = 10.5 Cylinder Center = (20, 20); Radius = 3.6; Height...
Given the following TestDriver.java public class TestDriver {       public static void main(String args[]) {             Point point...
Given the following TestDriver.java public class TestDriver {       public static void main(String args[]) {             Point point = new Point(10, 5);       Circle circle = new Circle(10.5, 20, 19);       Cylinder cylinder = new Cylinder(12, 3.6, 20, 20);                     System.out.println("Point");       System.out.println(point.toString()) ;       System.out.println("Circle");       System.out.println(circle.toString());       System.out.println("Cylinder");       System.out.println(cylinder.toString());       } } You will get the following result once you execute the TestDriver.java (after compiling it) Point (10, 5) Circle Center = (20, 19); Radius = 10.5 Cylinder Center = (20, 20); Radius = 3.6; Height...
public class Problem1 {    public static void partition(int[] A)    {        /*Rearrange the...
public class Problem1 {    public static void partition(int[] A)    {        /*Rearrange the array to have the following property:        Suppose the first element in the original array has the value x.        In the new array, suppose that x is in position i, that is data[i] = x.        Then, data[j] <= x for all j < I and data[j] > x for all j > i.        Thus, informally, all the...
For each call to the following method, indicate what console output is produced: public void mystery2(int...
For each call to the following method, indicate what console output is produced: public void mystery2(int n) { if (n <= 1) { System.out.print(n); } else { mystery2(n / 2); System.out.print(", " + n); } } mystery2(1); mystery2(4); mystery2(16); mystery2(30); mystery2(100);
Write in Java: Write a method called: public static String[] noIdenticalCombine(String[] array1, String[] array2) { //...
Write in Java: Write a method called: public static String[] noIdenticalCombine(String[] array1, String[] array2) { // instructions: returns an array that contains all the Strings in array1 and array2 but without repetition. order does not matter, but it will return array1's elements and then array2's element that are not in array1. Assume there are no duplicates are in array1 and array2. Could use count which is how many str there are in array2, where !contains(array1, str). May an array of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT