Question

In java - Question 5 (Which CASE? - 10 pts) – What is the output of...

In java -

Question 5 (Which CASE? - 10 pts) – What is the output of the following code?

CREATE x <-- 5

SWITCH (x) C

ASE 1: PRINTLINE (“hello world”)

BREAK

CASE 2: PRINTLINE (“hELLO wORLD”)

CASE 3: PRINT (“HELLO WORLD”)

BREAK

CASE 4: PRINTLINE(“Hello”)

CASE 5: PRINT(“World”)

BREAK

DEFAULT: BREAK

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public class SwitchCase {

    public static void main(String[] args) {
        int x = 5;
        switch (x) {
            case 1:
                System.out.println("hello world");
                break;
            case 2:
                System.out.println("hELLO wORLD");
            case 3:
                System.out.println("HELLO WORLD");
                break;
            case 4:
                System.out.println("Hello");
            case 5:
                System.out.println("World");
                break;
            default:
                break;
        }
    }

}

World

Add a comment
Know the answer?
Add Answer to:
In java - Question 5 (Which CASE? - 10 pts) – What is the output of...
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
  • PSUEDOCODE ONLY!! What is the output of the following code? CREATE x 1 SWITCH (x) Print...

    PSUEDOCODE ONLY!! What is the output of the following code? CREATE x 1 SWITCH (x) Print output here: Print output here: BREAK CASE 2: PRINTLINE (“hELLO wORLD”) CASE 3: PRINT (“HELLO WORLD”) BREAK CASE 4: PRINTLINE(“Hello”) CASE 5: PRINT(“World”) BREAK DEFAULT: BREAK

  • all in pseudocode Question 1) Warmup question: Write a function named True False() (only the function,...

    all in pseudocode Question 1) Warmup question: Write a function named True False() (only the function, no main is needed) that takes in a number and determines if it is evenly divisible by 5 (le, returns true or false). (15 points) Answer is in: Pseudocode CHO Java0 C+0 Page 17 Question 3) 2D Arrays The IRS has contracted you to process a 10x10 array of floating point numbers called Taxes and sum up all negative numbers in the array so...

  • need help with java questions The following snippet of code would produce what outcome? public static...

    need help with java questions The following snippet of code would produce what outcome? public static void main(String 2 [] args) { int day = 5; switch (day) { case 1: System.out.println("Monday "); case 2: System.out.println("Tuesday "); case 3: System.out.println("Wednesday "); case 4: System.out.println("Thursday "); case 5: System.out.println("Friday "); case 6: System.out.println("Saturday "); case 7: System.out.println("Sunday "); break; default: System.out.println("Invalid Day "); } } Invalid Day Friday Saturday Sunday Invalid Day Friday Friday Saturday Sunday What will be the output...

  • Question 5: Consider the following C++ program. switch(x) case 1: if (x > 1) case 2:...

    Question 5: Consider the following C++ program. switch(x) case 1: if (x > 1) case 2: if (x > 3) case 3: cout<<"Epic Beats!" << endl; case 4: cout << "Chill Vibes" << endl; break; case 5: cout << "Sweet Jazz" << endl; break; default: cout << "Invalid input. Try again."; A. What is the output if x = 1? B. What is the output if x = 3? C. What is the output if x = 2? D. What...

  • Please try to explain the answers as well. It will be highly appreciated. Output of the...

    Please try to explain the answers as well. It will be highly appreciated. Output of the following expression: 5 * 4 % 2 = ? Output of a loop: Example: What will be the output of the Java code (Assume all variables are properly declared.) num = 10; while (num <= 32)                 num = num + 5; System.out.println(num); What will be the output of the Java code (Assume all variables are properly declared.) public class test {   ...

  • 20) What is the output of the following segment of C code: int avg(int n, int*...

    20) What is the output of the following segment of C code: int avg(int n, int* a); int main () {             int array[4]={1,0,6,9};             printf("%d", avg(4, array)+ 1);             system("pause");             return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...

  • boolean a = ( true && false ); System.out.println( a ); what is the output of...

    boolean a = ( true && false ); System.out.println( a ); what is the output of this? is it true and false? int season = 3; switch ( season ) { case 1 : System.out.println( " Season is winter" ); break; case 2: System.out.println( "Season is Spring" ); break; case 3: System.out.println( "Season is Summer"); break; case 4: System.out,pritnln( "Season is Fall" ); break; default: System.out,pritnln( "Invalid season" ); what is the output of this code sequence? is it summer,...

  • Help! in Java, test values {0, 1, 3, 6, 10} I need this to print 107...

    Help! in Java, test values {0, 1, 3, 6, 10} I need this to print 107 but it keeps printing 75. What am I doing wrong???     public int switchCase( int []values) {        int sum = 0;        for(int i = 0;i<values.length;i++){            sum += values[i];               }                       int value = values.length;            switch (sum){               case 1:           ...

  • in c# 1- What is the output for total after the following segment of code executes?...

    in c# 1- What is the output for total after the following segment of code executes? int num = 3, total = 0; switch (num) {                case 1:                case 2:                               total = 5;                               break;                case 3:                               total = 10;                               break;                case 4:                               total = total + 3;                               break;                case 8:                               total = total + 6;                               break;                default:                               total = total + 4;                               break; } WriteLine("The value of total is " + total); The value displayed for total would be ....

  • Eclipse Java Oxygen Question 11 pts A compile-time error occurs when Group of answer choices c....

    Eclipse Java Oxygen Question 11 pts A compile-time error occurs when Group of answer choices c. there’s a syntax error in a Java statement a. the Java compiler can’t be located b. bytecodes can’t be interpreted properly c. there’s a syntax error in a Java statement Flag this Question Question 21 pts An error that lets the application run but produces the wrong results is known as a Group of answer choices d. syntax error c. logic error a. runtime...

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