aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • Java Programming Test
  • What is the output of the following code?public void test...
Multiple choice

What is the output of the following code?public void test(){boolean x=false;if(x = true){System.out.println(false);}else{System.out.println(true); }}

  1. Prints false

  2. Prints true

  3. Prints false true

  4. Prints true false

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

x is assigned true, so 'if' loop executes.

Keep practicing — related questions

  • What will be the output of the program? boolean bool = true; if(bool = false) /* Line 2 */ { System.out.pri...
  • What will be the output of the following? public void test(){boolean x;if(x){System.out.println(false);}els...
  • public void foo( boolean a, boolean b) { if( a ) { System.out.println("A"); /* Line 5 */ } else if(a && b) ...
  • What is the output of the following? public void test(){int x=0;if(x){System.out.println(false);}else{Syste...
  • What gets printed after this boolean b = false; if (b = true){ System.out.println("True"); }
  • What will be the output of the program? public class BoolTest { public static void main(String [] args) { i...
  • What will be the result of executing the following code? 1. boolean a = true; 2. boolean b = false; 3. bool...
  • What is the output of following block of program ? boolean var = false; if(var = true) { System.out.println...
Play the full quiz 🎤 Practise this topic out loud

Practice this topic

  • Programming Output Evaluation (1721 questions)
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy