Concept explainers
What output will be produced by the following code?
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Software Engineering (10th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Starting Out with Java: Early Objects (6th Edition)
Modern Database Management
C How to Program (8th Edition)
Starting Out with C++: Early Objects
- 9. What will the following print out? = 0; int num System.out.println("Song titles with numbers include: "); switch (num) { case 12: System.out.println("12 days of Christmas"); case 99: System.out.println("99 bottles of beer on the wall"); System.out.println("99 Luftballons"); case 7: System.out.println("7 Chinese Brothers"); case 50: System.out.println("50 Mission Cap"); default: System.out..println ("If I had a million dollars"); А. Song titles with numbers include: 7 Chinese Brothers 50 Mission Cap If I had a million dollars В. Song titles with numbers include: 7 Chinese Brothers С. Song titles with numbers include: 12 Days of Christmas 99 bottles of beer on the wall 99 LuftBallons 7 Chinese Brothers D. Song titles with numbers include: If I had a million dollarsarrow_forwardWhat is y ?Int x =1;Int y = x = x + 1;System.out.println(“y is “ + y);arrow_forwardWhat is the value of x after the following code executes? int x=10; if(x++ >10) { x =13; } a. 10 b.9 c.13 d.11arrow_forward
- int a = 10, b =7; System.out.println(a>b?a:b); Will always print what?arrow_forward2) What does this code output? int fun(int x, int y) { if (x == 0) return 1; x = x/ 2; y = y - 1; return fun(x, y) + x + y; int main() { int a = 10; %3D int b = 10; %3! int c = fun(a, b); printf("%i\n", c); %3D return 0; 11 15 23 39arrow_forwardWith the statement, With the statement, int option=1; switch(option){ int a=1; case 1: printf("1"); while(a<=10){ case 2: printf("2"); With the statement, a++; case 3: printf("3"); break; int x=0; a++; while(x!=20) { printf("%d", a); default: printf("“4"); x+=2; a++; } a+t; } What is the output of the given code? How many times this code will loop? What is the output? 357 syntax error О 123 infinite loop 159 10 5913 12 O 11 3711 O run time errorarrow_forward
- What is the output ? final int MIN = 10, MAX = 20;int num = 15;1. while (num < MAX) { System.out.print(num + “ “); num++;}2. while (num < MAX) { num++; System.out.print(num + “ “);}3. do { num++; System.out.print(num + “ “);} while (num <= MAX);4. while (num < MAX) { System.out.print(num + “ “); num--;}5. while (num > MIN) { System.out.print(num + “ “); num--;}6. while (num < MAX) { System.out.print(num + “ “); num += 2;}7. while (num < MAX) { if (num%2 == 0) System.out.print(num + “ “); num++;}8. do { num = num + 1; if (num * 2 > MAX + num) System.out.print(num + “ “);} while (num <= MAX);9. for (int value = 0; value >= 7; value++) System.out.print(value + “ “);10. for (int value = 7; value < 0; value--) System.out.print(value + “ “);11. for (int value = 1; value >= 20; value+=4) System.out.print(value + “ “);12. for (int value = num; value <= MAX; value++) System.out.print(value + “ “);13. for (int value = num; value <= MAX; value++) if…arrow_forward4 Write an if-else statement to output "Exceeds capacity" if the value of roomCapacity is greater than 161. Otherwise, output "Does not exceed capacity". End with a newline. Ex: If the input is 163, then the output is: Exceeds capacity 1 import java.util.Scanner; 3 public class Relational { 4 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int roomCapacity; L23456789 5 11 10 11 12 } 13 } roomCapacity = scnr.nextInt (); /* Your code goes here */ 2arrow_forwardif ( gender == 1 ) System.out.println( "Woman" ); else if ( gender == 1 ) System.out.println( "Man" ); correct the code and and identify the name of error in the a above code?arrow_forward
- What does the following code display: int value = 41; System.out.printin ( "Incrementing value: " if( value == 41 ) { System.out.println ( "Something went wrong with the increment : ("); }else if ( value == 42 ) { System.out.println ( "Ah, the answer to life the universe and everything :) ") : }else if ( value == 43 ) { System.out.println ( "Weird, really weird 8) "); + value++ ); Incrementing value: 41 Something went wrong with the increment :( Incrementing value: 41 Ah, the answer to life the universe and everything :) Incrementing value: 42 Ah, the answer to life the universe and everything :) Incrementing value: 42 Weird, really weird 8)arrow_forwardComplete the if-else statement to output "Below 90" if the value of userInput is below 90. Otherwise, output "90 or more". Ex: If the input is 88, then the output is: Below 90 1 import java.util.Scanner; 3 public class Relational { 345678 9 10 11 12 13 14 FREEdd public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userInput; 15 16 } 17 } userInput = scnr.nextInt (); if (* Your code goes here */) { System.out.println("Below 90"); } else { } System.out.println("90 or more");arrow_forwarda. What is wrong in the following code? i. double a = 7.0; int* p = sa; ii. int test = 1; int* pTest = &test; int i = pTest;arrow_forward
- 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