Тесты
Язык сайта: Русский
Українська
English
Русский
Тесты по программированию
Вход
Регистрация
Тесты по программированию
Теория
сниппеты
Статьи
Главная
Android
Цены
FAQ
История Cosmo
Правила и условия сервиса
Политика конфиденциальности
Политика в отношении файлов cookie
Обратная Связь
initialization
:
Язык контента: English
Русский
What will happen as a result of the following code? class A {} class B extends A {} public class Test { static public void main(String args[]) { B b = new B(); A a = b; if (a.hashCode() == b.hashCode()) System.out.print("Passed"); } }
initialization
What the following code will type? public class Test { { System.out.println("Block"); } int x = getX(); static { System.out.println("Static block"); } public int getX() { System.out.println("X variable"); return 5; } static int y = getY(); public static int getY() { System.out.println("Y variable"); return 6; } public static void main(String[] args) { Test m = new Test(); } }
initialization
What happens when you try to compile / run the following code: abstract class Animal { static { System.out.println("Inside Animal"); } } class Cat extends Animal { static { System.out.println("Inside Cat"); } } class Dog extends Animal { static { System.out.println("Inside Dog"); } } public class Main { public static void main(String[] args){ Animal cat = new Cat(); Animal dog = new Dog(); } }
initialization
What will be the result of the program execution? public class Tenor extends Singer { public static String sing() { return "fa"; } public static void main(String[] args) { Tenor t = new Tenor(); Singer s = new Tenor(); System.out.println(t.sing() + " " + s.sing()); } } class Singer { public static String sing() { return "la"; } }
initialization
What happens after you compile and run this code? public class MyClass{ static int i; public static void main(String[] args){ System.out.println(i); } }
initialization
What is the result of this code executing: class One { public static int j = 90; One() { j = 12; } } public class Test extends One { public static void main(String args[]) { new Test(); System.out.println(One.j); } }
initialization
What happens when you try to compile and run this code: 00: public class Test { 01: public static void main(String[] args) { 02: Object obj = new String("String object"); 03: String str = (String) new Object(); 04: System.out.println(obj); 05: System.out.println(str); 06: } 07: }
initialization
Which of the following statements in the given code are true? class A { A(int i) {} } // 1 class B extends A {} // 2
initialization
What happens as a result of compiling and running this code? class Class1 { Class1(int i) { System.out.println("Class1(int)"); } } public class Class2 extends Class1 { Class2(double d) { // 1 this((int) d); System.out.println("Class2(double)"); } Class2(int i) { // 2 System.out.println("Class2(int)"); } public static void main(String[] args) { new Class2(0.0); } }
initialization
What will be the output of following code? class A { { System.out.print("5"); } static { System.out.print("3"); } public A() { System.out.print("4"); } } public class B extends A { { System.out.print("2"); } static { System.out.print("6"); } public B() { System.out.print("1"); } public static void main(String[] args) { new B(); } }
initialization
← Предыдущая
2
3
4
5
6
Следующая →
Зарегистрируйся сейчас
или
Подпишись на будущие тесты