Question

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, fall, invalid season?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a=true&&false always evaluates to false

So output is false

season=3

the matching case=3 so "Season is summer" is printed

Add a comment
Know the answer?
Add Answer to:
boolean a = ( true && false ); System.out.println( a ); 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
  • Output of this in java? String season = ""; int n = 0; switch (season) {...

    Output of this in java? String season = ""; int n = 0; switch (season) { case "Spring": n = 16; break; case "Summer": n = 17; break; case "Fall": n = 18; break; case "Winter": n = 19; break; default: n = 20; break; } System.out.println(n);

  • JAVA 5) What is the output of the following code? int a = 70; boolean b...

    JAVA 5) What is the output of the following code? int a = 70; boolean b = false; if(a >= 70) { System.out.print(1); if(b==true) { System.out.print(2); } } else { System.out.print(3); if(b==false) { System.out.print(4); } } System.out.print(5); 6) What is the output of the code above using these initial values? int a = 43; boolean b = false; 7) The following method is SYNTACTICALLY correct (meaning it will compile). True or false? public boolean method() { int value = 5;...

  • 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...

  • Consider the interface Predicate defined as follows. interface Predicate { boolean eval(int j); } Recall that...

    Consider the interface Predicate defined as follows. interface Predicate { boolean eval(int j); } Recall that you can check if an integer “i” is even by using the expression “i%2 == 0”. Write a class IsEven that determines whether a number is even: class IsEven implements Predicate { public boolean eval(int j) { } } For example, the following code Predicate p = new IsEven(); if ( p.eval(2)) { System.out.println("2 is even"); } if (! p.eval(3)) { System.out.println("3 is not...

  • 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 {   ...

  • 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 ....

  • This is what I have so far. I'm getting an error on the ... case 3:...

    This is what I have so far. I'm getting an error on the ... case 3: System.out.println("Enter the rank of the card you want removed"); cards.remove(); System.out.println(); break; -------------------------------------- package PlayingCards; import java.util.Scanner; public class Driver { public static void main(String[] args) { Scanner sc = new Scanner(System.in); boolean done = false; int menuInput; DeckOfCards cards = new DeckOfCards(); do { System.out.println("Enter the number of one of the choices below:"); System.out.println("1: Shuffle The Deck."); System.out.println("2: Print The Cards Remaining In...

  • 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

  • What will be the output of the following Java code? class Output { public static void...

    What will be the output of the following Java code? class Output { public static void main(String args[]) { boolean a = true; boolean b = false; boolean c = a ^ b; System.out.println(!c); } } a) 0 b) 1 c) false d) true

  • Take your MonthDay class from Assignment #6 and modify it to throw an IllegalArgumentException when the user of the class attempts to pass an invalid value for month and year. Make sure you have your...

    Take your MonthDay class from Assignment #6 and modify it to throw an IllegalArgumentException when the user of the class attempts to pass an invalid value for month and year. Make sure you have your main method(function) in a separate source file demonstrating use of the try/catch block to catch the IllegalArgumentException that the MonthDay class may throw in the event of an invalid month, or year. class MonthDays {    private int month;    private int year;    public MonthDays(int aMonth, int...

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