Тесты
Язык сайта: Русский
Українська
English
Русский
Тесты по программированию
Вход
Регистрация
Тесты по программированию
Теория
сниппеты
Статьи
Главная
Android
Цены
FAQ
История Cosmo
Правила и условия сервиса
Политика конфиденциальности
Политика в отношении файлов cookie
Обратная Связь
initialization
:
Язык контента: English
Русский
What result will give the following code? public class A { public int i = 0; public A() { i = 10; } public static void main(String[] args) { int i = 9; A a = new A(); while(a.i < 10) a.doIt(); //9 } public static void doIt() { i++; //12 System.out.println("Hello"); } }
initialization
What will be the result of the program? package tutorial.base; public class TypesTutorial { public static void main(String... args) { A alpha = new B(); } } class A { A(){ System.out.print("A"); a(); } void a() { System.out.print("a"); } } class B { B() { System.out.print("B"); a(); } void a() { System.out.print("b"); } }
initialization
Will the following code compile? public class Person { public final String name; int age; }
initialization
What happens if you run this code: class Test { List<Integer> list; Test(){ list = new ArrayList<Integer>(); someVoid(list); } void someVoid(List<Integer> l){ l.add(0); l=null; } public static void main(String[] args) { Test test=new Test(); System.out.println("Size is: "+test.list.size()); } }
initialization
What happens when you try to compile and run this code: public class QTest { { System.out.print("1"); } public static void main(String[] args) { System.out.print("2"); new QTest(); } static { System.out.print("3"); } }
initialization
What will be printed as the result of the following code execution? public class GoodbyeWorld { public static void main(String[] args) { System.out.print(A.i); System.out.print(B.i); } } class A { static { i = 2; } static int i = 1; }; class B { static int i = 1; static { i = 2; } };
initialization
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: }
initialization
What is the result of the following code compilation and execution? public class Main{ final int x = 1; public static void main(String [] str) { int x = 2; //1 for (x = 3 ; x < 5 ; x++); //2 System.out.println("x=" + x); } }
initialization
What will be the output of the following code? class Clazz { { System.out.println("non-static init"); } public static void main(String a[]) { System.out.println("main"); Clazz ob1 = new Clazz(); } static { System.out.println("static init"); } }
initialization
What will be printed after compiling and running the following code? public class Test { public static void main(String[] args) { Sub sub = new Sub(); System.out.println(sub.getWidth()); } } class Sub extends Base { private Dimension size; public Sub() { this.size = new Dimension(50, 50); } public Dimension getSize() { return size; } } class Base { private int width; private int height; private Dimension size = new Dimension(20, 20); Base() { this.width = getSize().width; this.height = getSize().height; } Dimension getSize() { return size; } int getWidth() { return width; } int getHeight() { return height; } }
initialization
← Предыдущая
2
3
4
5
6
Следующая →
Зарегистрируйся сейчас
или
Подпишись на будущие тесты