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
operators
:
Content language: English
Русский
What will be the output of the following code: public static void main(String[] args) { int i = 10; Integer x = new Integer(10); if(x == i) { System.out.print("true"); } else { System.out.print("false"); } }
operators
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"); } } }
operators
What will be printed after compilation and running of the following code? double d1 = 1024.0d; double d2 = 1.0e-13d; double sum = d1 + d2; if (sum > d1) { System.out.println(">"); } else if (sum < d1) { System.out.println("<"); } else if (sum == d1) { System.out.println("=="); }
operators
What will be printed into console after executing next piece of code: public class Test { public void checkCase(int i) { switch (i&01) { case 1: System.out.println("Case 1"); case 2: System.out.println("Case 2"); default: System.out.println("Default"); case 3: System.out.println("Case 3"); } } public static void main(String[] args) { Test test = new Test(); test.checkCase(-1); } }
operators
What will be the output of the following code? class Main { public static void main(String[] args) { Boolean b1 = true; boolean b2 = false; boolean b3 = true; if ((b1 & b2) | (b2 & b3) & b3) System.out.print("alpha "); if((b1 = false) | (b1 & b3) | (b1 | b2)) System.out.print("beta "); } }
operators
What will be the result of compiling and running the following code? public class MyFirst { static public void main(String[] args) { //1 int a = 5; a = a!=0 ? a>1 ? a>>2 : a<<2 : a<1 ? a<<2 : a>>2; //2 System.out.println(a); } }
operators
What will be the result of compilation and execution of the following code: class User { private int id = 0; private String name; private String surname; public User () {} public User (int id, String name, String surname) { this.id = id; this.name = name; this.surname = surname; } Override public boolean equals (Object obj) { if (this == obj) return true; if (obj == null ||! getClass (). equals (obj.getClass ())) return false; User u = (User) obj; return id == u.id & Amp; & amp; name == u.name || (name! = null & amp; & amp; name.equals (u.name)) & Amp; & amp; surname == u.surname || (surname! = null & amp; & amp; surname.equals (u.surname)); } Override public int hashCode () { return id + name == null? 0: name.hashCode () + surname == null? 0: surname.hashCode (); } public static void main (String args []) { User u1 = new User (12, "name", null); User u2 = new User (12, null, "name"); System.out.println (u1.hashCode () == u2.hashCode ()); System.out.println (u1.equals (u2)); } } </ Code> </ pre>
operators
What will the following code print out: public class Increments { public static void main(String[] args) { int i = 0; i = i++ + i++; System.out.println(i); } }
operators
Considering these variable declarations, which of the following statements are correct? byte b = 1; char c = 1; short s = 1; int i = 1;
operators
What will be the output of the following code: public class Main { public static void main (String []args) { int z = 1; z += z += z += z += z; System.out.println(z); } }
operators
← Prev
2
3
4
5
6
Next →
Sign Up Now
or
Subscribe for future quizzes