Quizzes
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
booleans
:
Content language: English
Русский
What will the following code print out: public class Test { public static boolean methodOne() { System.out.println("methodOne "); return false; } public static boolean methodTwo() { System.out.println("methodTwo "); return true; } public static boolean methodThree() { System.out.println("methodThree "); return true; } public static void main(String[] args){ System.out.println(Test.methodOne() || Test.methodTwo() || Test.methodThree()); } }
booleans
What number of different objects will variables b1 - b11 refer to after the following code execution? Boolean b1 = true; Boolean b2 = true; Boolean b3 = true; Boolean b4 = true; Boolean b5 = true; Boolean b6 = true; Boolean b7 = true; Boolean b8 = true; Boolean b9 = new Boolean(true); Boolean b10 = new Boolean(true); Boolean b11 = new Boolean(true);
booleans
What should be placed instead of ... in order to get a "I will be a good citizen." result? public class Test { public static void main(String[] args) throws Exception { boolean toBe = ... PrinceOfDenmark hamlet = new PrinceOfDenmark(); hamlet.tortureYourSelf((toBe || !toBe)); } } class PrinceOfDenmark { void tortureYourSelf(boolean mind) { if (mind) { System.out.println("I will hate everybody including myself!"); } else { System.out.println("I will be a good citizen."); } } }
booleans
What will be the result of the following code compilation and execution? public class Main { public static void main(String [] str) { Boolean value = new Boolean("true"); System.out.println(value); value = new Boolean("tRuE"); System.out.println(value); value = new Boolean("test"); System.out.println(value); value = new Boolean(true); System.out.println(value); value = true; System.out.println(value); } }
booleans
What will be printed out if the following code is compiled and executed? public class Main { public static void main(String s[]) { System.out.println(true ? false : true == true ? false : true); } }
booleans
What is the result of the following program execution? public class A { public static void main(String[] args) { Boolean b1 = true; Boolean b2 = new Boolean("/false"); String s1 = "" + 1 + '+' + 1 + '=' + (1 + 1) + " is "; String s2 = s1 + b1 + '/' + b2; System.out.println(s2); } }
booleans
Which of the following options are correct?
booleans
What is the result of the following code execution? Boolean b = new Boolean("Hello"); System.out.println(b);
booleans
What will happen when the following code is compiled and run? 1: public class Clazz { 2: public boolean flags[] = new boolean[2]; 3: public static void main(String[] args){ 4: Clazz clazz = new Clazz(); 5: System.out.println("flags[1] = " + clazz.flags[1]); 6: } 7: }
booleans
How many times will the word "Hello" be printed? public class Inc { static int x = 0; static boolean ok = true; static boolean f() { x++; return (ok = !ok); } public static void main(String[] args) { if (f()||f()|f()) { for (int i=0; i<x; i++) System.out.println("Hello"); } } }
booleans
← Prev
1
2
Next →
Sign Up Now
or
Subscribe for future quizzes