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
loops
:
Content language: English
Русский
What will be the result of the program? public class MyTest { public static void main(String[] args) { label1: for (int i = 0; i < 3; i++) { if (i == 1) continue label1; label2: System.out.print("TEST "); label3:; } } }
loops
What happens at compilation and ruing of this piece of code? int i = 0, j = 5; tp: for (;;) { i++; for (;;) { if (i > --j) { break tp; } } System.out.println("i =" + i + ", j = " + j); }
loops
What happens when you'll try to compile and run this code: import java.util.*; public class Clazz { public static void main(String[] args) { List arrayList = new ArrayList(); arrayList.add("str1"); arrayList.add("str2"); arrayList.add("str3"); for (int i = 0; i < arrayList.size(); i++) arrayList.remove(i); System.out.println(arrayList.size()); } }
loops
What will be printed as a result? public class Test { public static void main(String[] s) { for (int i = 2; i < 10; i = (i++) + i--, i++) { System.out.print(--i); } } }
loops
What is the result of the program? public class B { public static void main(String[] args) { big_loop: for (int i = 0; i < 3 ; i++) { try { for (int j = 0; j < 3 ; j++) { if (i == j) continue; else if (i > j) continue big_loop; System.out.print("A"); } } finally { System.out.print("B"); } System.out.print("C"); } } }
loops
What happens when you compile and run the following code? public class Test { static int[] arrInstance = new int[100]; public static void main(String[] args) { byte[] arrLocal = new byte[100]; for (int i = 0; i < 100; i++) if (arrInstance[i] != arrLocal[i]) { throw new IllegalStateException("error"); } } }
loops
What will the program bring to the console? public class Test { public static void main(String[] args) { boolean b = true; int x = 0; do { if (x++ > 5) b = false; System.out.print(x); } while (b); } }
loops
What will be the result of displaying this code? public class Main { static int method() { for (int i = 0; i < 5; i++) { System.out.println("i = " + i); try { if (i == 1) { throw new Exception(); } } catch (Exception e) { System.out.println("Exception!"); return i; } finally { System.out.println("Finally block"); } } return -1; } public static void main(String[] args) { System.out.println("method() returned " + method()); } }
loops
What is the result of the following program: public class Foo { public static void main(String[] args) { for (int k = 1; k <= 10; k++) { if (k % 5 == 0) break label; System.out.print(k + " "); } label: { System.out.print("stop!"); } } }
loops
1. int x = 10; 2. do { 3. x--; 4. } while(x < 10); How many times will the line 3 be executed?
loops
← Prev
1
2
3
Next →
Sign Up Now
or
Subscribe for future quizzes