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

What will be the output of the following?

public void test(){boolean x;if(x){System.out.println(false);}else{System.out.println(true); }}

  1. Prints false

  2. Prints true

  3. Runtime error

  4. Compilation error

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

Local variable x is not initialised.

Keep practicing — related questions

  • What is the output of following block of program ? boolean var = false; if(var = true) { System.out.println...
  • Output?? boolean var = false; if(var = true) { System.out.println(“TRUE”); } else { System.out.println(“FAL...
  • What is the output of following block of program ? boolean var = false; if(var = true) { System.out.println...
  • What will be the output of the below code snippet? public class Quiz6 { public static void main(String[] ar...
  • What is the output of the following code?public void test(){boolean x=false;if(x = true){System.out.println...
  • What will be output of the following program? class A { boolean b; public static void main(String arg[]){ S...
  • What is the output for the below code ? public class Test { public static void main(String[] args) { Boolea...
  • public class Test { public static void main(String [] args) { int x =5; boolean b1 = true; boolean b2 = fal...
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