Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What is the return value of calc(0,0)? public static int calc( int x, int y ) { if (x == 0 ) { return y
What is the return value of calc(0,0)? public static int calc( int x, int y ) { if (x == 0 ) { return y + 1; } if ( y == 0) { return x - 1; } return x / y; } What is the value of calc(1,0)? public static int calc( int x, int y){ if (x == 0 ) { return y + 1; } if ( y == 0 ) { return x - 1; } return x / y: } Again, what is the value of calc( 4,5)? public static int calc( int x, int y){ if (x == 0) { return y + 1; } if (y == 0) { return x - 1; } return x / y; } Of 1, 2, and 3, which ones produce the same return value for all combinations of parameter values received? public static int calc( int x, int y ) { if (x == 0 ) { return y + 1; } if (y=0) { return x - 1; } return x/y; } 1. public static int calc( int x, int y){ if (y == 0) { return x - 1; } if (x == 0 ) { return y + 1; } else return x / y; } 2. public static int calc( int x, int y ) { if (x == 0 ) { return y + 1; } else if ( y == 0 ) { return x - 1; } else return x / y; } 3. public static int calc( int x, int y){ if ( x != 0 && y != 0 ) { return x / y; } if (x == 0 ) { return y + 1; } else { return x - 1; } When this code is compiled and run, if the user types 4.5 and presses "return", what output is generated? Scanner keyboard = new Scanner(System.in); System.out.print("Enter some value:" ); if ( keyboard.hasNext() ) { String token = keyboard.next(); System.out.println( "You've entered: + token): } Let x and y be two int variables where we know for sure that y is not 0. If you want write a condition for "x is a multiple of y", which one is correct? Select an answer and submit. For keyboard navigation, use the up/down arrow keys to select an answer. a x/y== 0 b x/y!= 0 C x% y== 0 d x%y!= 0 What is the correct syntax for throwing IllegalArgumentException with the parameter value "Not good!"? Select an answer and submit. For keyboard navigation, use the up/down arrow keys to select an answer. a throw illegalArgumentException( "Not good!"); b throw new IllegalArgumentException("Not good!"); throw illegalArgumentException() + "Not good!"; throw new IllegalArgumentException() + "Not good!"; Recall that nextLine() reads a entire line and a Scanner can be initialized to read tokens from a String. Suppose the user enters "I love you!" and presses returns. Will the program output "Success!"? Scanner keyboard = new Scanner(System.in); String w = keyboard.nextLine(); if ( w.hasNext()) { String token = w.next(); if ( w.hasNext()) { token = keyboard.next(); System.out.println("Success!" ); } } Select an answer and submit. For keyboard navigation, use the up/down arrow keys to select an answer. a yes b no
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started