Тести
Мова сайту: Українська
Українська
English
Русский
Тести з програмування
Вхід
Реєстрація
Тести з програмування
Теорія
Сніпети
Статті
Головна
Android
Ціни
FAQ
Історія Cosmo
Правила та умови сервісу
Політика конфіденційності
Політика щодо файлів cookie
Зворотній Зв’язок
inheritance
:
Мова контенту: English
Русский
What will be the result of compiling and running this code? class A {} interface I {} class B extends A implements I {} public class OverloadTest { static public void foo(A a) { System.out.print("A"); } static private void foo(B b) { System.out.print("B"); } static private void foo(I i) { System.out.print("I"); } public static void main(String[] args) { A a = new B(); OverloadTest.foo(a); OverloadTest.foo((I) a); } }
inheritance
Which class that implements the interface AA and returns the amount of the return value of a() of two given classes is declared correctly: interface AA { int a(); } class A implements AA { public int a() { return 1; } } class B implements AA { public int a() { return 1; } }
inheritance
What will the following code print: public class Funcs extends java.lang.Math { public int add(int x, int y) { return x + y; } public int sub(int x, int y) { return x - y; } public static void main(String[] a) { Funcs f = new Funcs(); System.out.println("" + f.add(1, 2)); } }
inheritance
What will happen as a result of compiling and running the following code? class A { int i = 0; public int increment() { return ++i; } } public class B extends A { int i = 1; // 1 public int increment() { return ++i; } public static void main(String[] args) { B b = (B) new A(); // 2 System.out.println(b.increment()); } }
inheritance
What will be displayed? class A { int i = 0; public int increment() { return ++i; } } public class B extends A { int i = 10; public int increment() { return ++i; } public static void main(String[] args) { A obj = (A) new B(); System.out.println(obj.increment()); } }
inheritance
try { int a = 0; int b = 42/a; System.out.print("A"); } catch (Exception e) { System.out.print("C"); } catch (ArithmeticException e) { System.out.print("B"); }
inheritance
What will be the result of a: class Clidders { public final void flipper() { System.out.println("Flip a Clidder"); } } public class Clidlets extends Clidders { public void flipper() { System.out.println("Flip a Clidlet"); super.flipper(); } public static void main(String [] args) { new Clidlets().flipper(); } }
inheritance
Why annotation @Override is needed when you redefine (or realize) methods?
inheritance
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); } }
inheritance
What will be the result of the launch of this code? package tutorial.base; public class TypesTutorial { public static void main(String... args) { A alpha = new B(0); } } class A { A(int x){ // - 1 - a(x); // - 2 - } void a(int x) { System.out.println("A-a: " + x); } } class B extends A { B(int x) { // - 3 - a(x); // - 4 - } void a(int x) { System.out.println("B-a: " + x); } }
inheritance
← Попередня
1
2
3
4
5
Наступна →
Зареєструйся Зараз
або
Підпишись на майбутні тести