Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
For each call to the following method, indicate what value is returned:
public int mystery4(int x, int y) { if (x < y) { return x; } else { return mystery4(x - y, y); } }
mystery4(6, 13)
mystery4(14, 10)
mystery4(37, 10)
mystery4(8, 2)
mystery4(50, 7) |
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- For each call to the following method, indicate what console output is produced: public void mystery1(int n) { if (n <= 1) { System.out.print(n); } else { mystery1(n / 2); System.out.print(", " + n); } } mystery1(1); mystery1(4); mystery1(16); mystery1(30); mystery1(100);arrow_forward4 - question Given the following method; public static void mystery(int x, int y) { if (x < y) { System.out.println (x); } else { mystery (x-y, y); } } What is the output produced by following method call: mystery(14, 10) а. 4 b. 14 С. 10 d. -4arrow_forwardThe following technique is used in a game of chess: canMoveTo(int x, int y), boolean. A method in the Piece class returns if the piece may travel to position (x, y). Describe how you would put this method to the test.arrow_forward
- Given the following methods: public static int addNumPlusMore(int num1, int num2) { return num1 + num2 + 5; } public static int addNumPlusMore(int num1, int num2, int num3) { return num1 + num2 + num3 + 10; } int val = addNumPlusMore(5, 5); What would val be set to after the following statement: choose from this 5 20 10 15arrow_forward// Sharissa Sullivan // COP 2250// Chapter 6 Method// Method with No permeters package sullivan4; import java.util.*; public class Sullivan4_2 { // Define a method for the flip of a coin - heads or tails class main { public static String toss() {// Create Random Number object for heads/tails toss Random randomNumber = new Random();// Generate a random number: heads = 0, tails = 1 int flip = randomNumber.nextInt(2);// If statement to flag flips with heads or tails if (flip == 0) return "heads"; else return "tails"; }// Define the main method public main(final String[] args) { // public static void main(String[] args)// Create Scanner object Scanner userinput = new Scanner(System.in);// Prompt the user to enter how many times they want the coin to be tossed System.out.println("How many times should I toss the coin ?");// Scan the value the user enters int scan =…arrow_forwardDetermine whether each statement below is true or false. Assume no index is out of bounds. Write either "true" or "false" on each line. Note: The Math.random() method returns a pseudorandom double type number greater than or equal to 0.0 and less than 1.0. int[] a = new int[6]; int[] b = new int[6]; int[] c = a; c[0] = 3;arrow_forward
- 25 def iceCreamOrder (cost flavor # vanilla 26 27 28 29 30 31 32 def run(): 33 34 35 36 37 38 = 6): input ("What flavor would you like?\n") return "The flavor print(iceCreamOrder ())] " + flavor + will cost printStatement() print (returnValues()) print (parameters (1,4)) print (parameters (5,7)) print (iceCreamOrder()) return #Do NOT change anything in this line! + str(cost) + " dollars."arrow_forwardNo written by hand solution Java Please Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish methodName()" followed by a newline, and should return -1. Example output: FIXME: Finish getUserNum() FIXME: Finish getUserNum() FIXME: Finish computeAvg() Avg: -1 import java.util.Scanner; public class MthdStubsStatistics { //solution here public static void main(String [] args) { int userNum1; int userNum2; int avgResult; userNum1 = getUserNum(); userNum2 = getUserNum(); avgResult = computeAvg(userNum1, userNum2); System.out.println("Avg: " + avgResult); } }arrow_forward(3) public static void test_b(int n) { if (n>0) test_b(n-2); System.out.println(n + " "); Consider the following method: What is printed by the call test_b(4)? A. 0 2 4 B. 0 2 C. 2 4 D. 4 2 E. 4 20 3 (4) What is the efficacy class of +? n 3 A: ©(1) B: O (log n) C: O (n) D: O (n log n) E: Θ n)arrow_forward
- 8 - question Given the following method; public void mysteryXY (int x, int y) { if (y == 1) { System.out.print (x); } else { System.out.print (x * y + " "); mysteryXY(x, y - 1); System.out.print(", " + x * y); } } What is the output produced by following method call: mysteryXY(4, 3); а. 16, 12, 8, 4, 8, 12, 16 b. 12, 8, 4, 8, 12 с. 8,4, 8 d. 4arrow_forward2. A pentagonal number is defined as n(3n-1)/2 for n = 1, 2, ..., etc.. Therefore, the first few numbers are 1, 5, 12, 22, ... . Write a method with the following header that returns a pentagonal number: %3D public static int getPentagonalNumber(int n) For example, getPentagonalNumber(1) returns 1 and getPentagonalNumber(2) returns 5. Write a test program that uses this method to display the first 100 pentagonal numbers with 10 numbers on each line. Numbers are separated by exactly one space.arrow_forwardConsider the following method: public static void method (int x, int y) { if (x < y) { method (x+1, y); System.out.print (x + " "); } } What will happen as the result of calling method (2,6)? (Select all correct answers) output will be 6 5 4 3 2 Program goes to an infinite loop because of errors in recursive calls 5 recursive calls will be made from method (3,6) to method (7,6) output will be 5 4 3 2 method (6, 6) will be called inside of the recursion 4 recursive calls will be made from method (3,6) to method (6,6) method (5, 6) will be called inside of the recursionarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education