Java Code

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What will be the value of and after the following code has been executed? int x = 90, y = 55, ans = 10; if (x == y) ans *= 2;

10

What will be the value of and after the following code has been executed? int ans = 10; int x = 65; int y = 55; if (x > y) ans = x + y;

120

How many times will the following for loop be executed? for int count = 10; count < 25; count++) System.out.println("Hello World!!!");

25

What will be the value of ans, x and y after the following statements are executed? int ans = 0, x = 15, y = 25; if ( x >= y) { ans = x + 10; x -=y; } else { ans = y + 10; y += x; }

ans = 35 x = 15 y = 40

What will be the value of ans, x and y after the following statements are executed? int ans = 35. x = 50, y = 50; if ( x < y ) { ans = x + 10; x -= y; } else { ans = y + 20; y += x;

ans = 70 x = 50 y = 100

What will the ltd and strSize be as a result of executing the following code? int = 12; String msg = "I love the Spring."; char ltr = msg.charAt(x); int strSize = msg.length(); System.out.println("Character at index x = " + ltr); System.out.println('msg has " + strSize + " characters.");

ltr will = p strSize will = 18

How many times will the following do while loop be executed? int x = 11; do { x+=2-; } while ( x> 100);

one time

What will be the value of x after the following code is executed? int x = 10; while ( x < 100) { x +=10; }

x = 100

What will be the value of x after the following code is executed? int x = 10; do { x * = 20; ) while (x<5);

x = 200

What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x+=y; y+=2-; }

x = 210

What will be the value of x after the following code is executed? int x = 10; for ( int y = 5; y < 20; y += 5) x +=y;

x =40

How many times will the following do while loop be executed? int x = 11 do { x += 20; } while (x<=100);

5 times

What would be the value of bonus after the following statements are executed? int bonus, sales = 75000; char dept = 'S'; if (sales > 100000) if ( dept == 'R') bonus = 2000; else bonus = 1500; else if (sales > 65000) if ( dept == 'S'_ bonus = 1250; else if bonus 1000; else if bonus = 0;

bonus = 1250

What will be the value of bonus after the following code is executed? int bonus, sales = 7500; if (sales < 5000) bonus = 200; else if (sales < 7500) bonus = 500; else if ( sales < 10000) bonus = 750; else if ( sales < 20000) bonus = 1000; else if bonus - 1250;

bonus = 750

What would be the value of bonus after the following statements are executed? int bonus, sales = 1250; if (sales > 1000) bonus = 100; if ( sales > 750) bonus = 50; if (sales > 500) bonus = 25; else bonus = 0;

bonus =25

What will be the value of the discountRate after the following statements are executed? double discountRate = .02; int purchase = 100; if (purchase > 1000) discountRate = .05; else if (purchase > 750) discountRate = .03; else if (purchase > 500) discountRate = .01;

discountRate = .02

What will be the value of the discountRate after the following statements are executed? double discountRate = .02; int purchase = 100; if (purchase > 950) discountRate = .05; if (purchase > 750) discountRate = .04; if (purchase > 500) discountRate = .03; else discountRate = .02;

discountRate = .03

What will be the value of the discountRate after the following statements are executed? double discountRate char custType = 'B'; switch (custType) { case 'A' discountRate = .08; case 'B' discountRate = .06; case 'C' discountRate = .04; break; default; discountRate = .0; }

discountRate = .04

What will be the value of the discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 1250; char just = 'N'; if (purchase > 1000) if ( just == 'Y') discountRate = .05; else if ( purchase > 750) if ( just == 'Y' discountRate = .03; else discountRate = .02; else discountRate = 0;

discountRate = .04


संबंधित स्टडी सेट्स

Unit 3: Capital Gains Tax Shelters for Investment Properties Unit Exam

View Set

Chapter 28 Growth and Development of the School-Age Child

View Set