Question

mystery (numi, num2) ? public static void main(String[] args) int numl = 7; int num2 = 13; int result = mystery (numi, num2);
int secondNum) firstNum = firstNum * 3; secondNum = secondNum * 2; return firstNum + secondNum; numl: A/ num2: result: A Prev
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Given code:

public static void main(String[] args)
   {
   int num1=7;
   int num2=13;
   int result=mystery(num1,num2);

   }
   public static int mystery(int firstNum,int secondNum)
   {
   firstNum=firstNum*3;
   secondNum=secondNum*2;
   return firstNum+secondNum;
   }

ANSWER:

num1 = 7

num2 = 13

result = 47

EXPLANATION: initially num1 and num2 are initilized with some values.

and these two values are passing to the function mystery()

and perform operations on these values:

firstNum=firstNum*3;
   secondNum=secondNum*2;
   return firstNum+secondNum;

and return the result

I EXECUTE THE ABOVE CODE WITH ADDING SOME PRINT STATEMENTS.

CODE:

public class Main
{
   public static void main(String[] args)
   {
   int num1=7;
   int num2=13;
   System.out.println("The num1: "+num1);
       System.out.println("The num2: "+num2);
   int result=mystery(num1,num2);
       System.out.println("The result: "+result);
      
   }
   public static int mystery(int firstNum,int secondNum)
   {
   firstNum=firstNum*3;
   secondNum=secondNum*2;
   return firstNum+secondNum;
   }
}

OUTPUT:

The numl: 7 The num2: 13 The result: 47 ... Program finished with exit code 0 Press ENTER to exit console..

SCREENSHOT OF THE CODE:

4- Main.java 1 public class Main 2 { 3 public static void main(String[] args) { 5 int num1=7; 6 int num2=13; 7 System.out.pri

Add a comment
Know the answer?
Add Answer to:
mystery (numi, num2) ? public static void main(String[] args) int numl = 7; int num2 =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please answer both questions thank you. Question 49 (1 point) What is wrong with the following...

    Please answer both questions thank you. Question 49 (1 point) What is wrong with the following code snippet? for (int i 1; i <= 5; i++) { int squared = i + i; System.out.println(i + IT "! squared = + squared); } System.out.println("Last square = " + squared); calculation error variable scope error O nothing incorrect use of for loop Question 47 (1 point) What are the values of num1 and num2 and result after the execution of mystery (num1,...

  • What output is produced by the following program? public class MysteryNums public static void main(String[] args)...

    What output is produced by the following program? public class MysteryNums public static void main(String[] args) - int x = 12; int y = x - 3; 3, sentence (y, x + y); . public static void sentence (int numi, int num2) { 4: System.out.println(num1 + " + num2);

  • What does this program print? package javaapplication210; public class JavaApplication210 { public static void main(String[]args){ System.out.printf("Result...

    What does this program print? package javaapplication210; public class JavaApplication210 { public static void main(String[]args){ System.out.printf("Result is: % d/n", mystery (-5, -9));//System.out.printf("Result is: % d/n", mystery (-4, -8));//System.out.printf("Result is: % d/n", mystery (-6, -7));//} public static int mystery(int a, int b) { if(b - 1) returns a; else return a + mystery(a, b + 1); } }

  • What are the errors in this ? public class Mystery { public static void main(String[] args)...

    What are the errors in this ? public class Mystery { public static void main(String[] args) { double initialSavings = 10000; double interestRate = 0.05; double currSavings = 0; int i;    System.out.println("\nAnnual savings 5 years: "); currSavings = initialSavings; for (i = 0, i < 5, ++i); currSavings = (currSavings * interestRate); System.out.println("$" + currSavings); }    }

  • how to change this code to string instead of int    public static void main(String[] args)...

    how to change this code to string instead of int    public static void main(String[] args) {        int[] sample = { 212, 580, 6, 7, 28, 84, 112, 434};        Dictionary bst = new Dictionary();        for (int x : sample) {            bst.insert(x);        }        System.out.println(bst.find(65));        System.out.println(bst.smallest());        System.out.println(bst.largest()); //       bst.delete(84);        System.out.println(bst.numOfLeafNodes());        System.out.println(bst.height());        bst.traverseInOrder();    } }

  • What is printed by running the following code? public static void main(String[] args) { int[] nums...

    What is printed by running the following code? public static void main(String[] args) { int[] nums = {2, 3, 4}; int n = 5; changeMe1(n, nums); System.out.print( n ); System.out.print(nums[0]); changeMe2(n, nums); System.out.print( n ); System.out.print(nums[0]); } public static void changeMe1(int number, int[] list) { number++; list[0]++; } public static void changeMe2(int number, int[] list) { number = 9; list = new int[1]; list[0] = 99; }

  • Java, how would i do this public static void main(String[] args) { int n = 3;...

    Java, how would i do this public static void main(String[] args) { int n = 3; int result; result = factorial(n); + public static int factorial(int n) public static int factorial(int n) n = 3 { returns 3* 2 * 1 { if (n == 1) return n; else return (n * factorial(n-1)); if (n == 1) return n; else return (3 * factorial(3-1)); ܢܟ } public static int factorial(int n) n = 2 public static int factorial(int n) returns...

  • What is the Java output? Part One: class Driver { public static void main(String[] args) {...

    What is the Java output? Part One: class Driver { public static void main(String[] args) { int a = 5; int b = 3; if (a < b || a * 2 < b) System.out.print(a - b); System.out.print(b + a); } } Part Two: class Driver { public static void main(String[] args) { int a = 5; int b = 8; if (a < b) if (a * 2 < b) System.out.print("foo"); else System.out.print("bar"); else System.out.print("buz"); } }

  • 1. What is the output when you run printIn()? public static void main(String[] args) { if...

    1. What is the output when you run printIn()? public static void main(String[] args) { if (true) { int num = 1; if (num > 0) { num++; } } int num = 1; addOne(num); num = num - 1 System.out.println(num); } public void addOne(int num) { num = num + 1; } 2. When creating an array for primitive data types, the default values are: a. Numeric type b. Char type c. Boolean type d. String type e. Float...

  • import java.util.Arrays; public class lab {    public static void main(String args[])    {    int...

    import java.util.Arrays; public class lab {    public static void main(String args[])    {    int arr[] = {10, 7, 8, 9, 1, 5,6,7};    int arr2[] = {9, 8, 7, 6, 5, 4, 3, 2, 1};    int arr3[] = {1, 3, 5, 3, 2, 6, 20};    quicksort(arr,0,arr.length-1);    quicksort(arr2,0,arr2.length-1);    quicksort(arr3,0,arr3.length-1);    System.out.println(Arrays.toString(arr));    System.out.println(Arrays.toString(arr2));    System.out.println(Arrays.toString(arr3));       }    private static int partition(int[] items,int low, int high)    {    int i=0;    int j=0;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT