Тести
Мова сайту: Українська
Українська
English
Русский
Тести з програмування
Вхід
Реєстрація
Тести з програмування
Теорія
Сніпети
Статті
Головна
Android
Ціни
FAQ
Історія Cosmo
Правила та умови сервісу
Політика конфіденційності
Політика щодо файлів cookie
Зворотній Зв’язок
inheritance
:
Мова контенту: English
Русский
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(); } }
inheritance
What is the result of compiling and running the following code? class Base { public String name = "Base"; public String getName() { return name; } } class Sub extends Base { public String name = "Sub"; public String getName() { return name; } } public class Program { public static void main(String[] args) { Sub s = new Sub(); Base b = s; System.out.println(b.name); } }
inheritance
What will be printed as a result of compiling and running this code? public class TestClass { public static void main(String[] args) { Base sub = new Sub(); sub.test(); } } class Base { public static void test() { System.out.println("Base.test()"); } } class Sub extends Base { public static void test() { System.out.println("Sub.test()"); } }
inheritance
Whether the class inherits the constructors of its superclass?
inheritance
What will be displayed? class A { int x = 1; public void printX() { System.out.println(getX()); } public int getX() { return x; } } class B extends A { int x = 2; public int getX() { return x + 1; } } public class Test { public static void main(String[] args) { A classA = new B(); classA.printX(); } }
inheritance
What happens during compiling and executing the code: public class GoTest { public static void main(String[] args) { Sente a = new Sente(); a.go(); Goban b = new Goban(); b.go(); Stone c = new Stone(); c.go(); } } class Sente implements Go { public void go() { System.out.println("go in Sente"); } } class Goban extends Sente { public void go() { System.out.println("go in Goban"); } } class Stone extends Goban implements Go { } interface Go { public void go(); }
inheritance
What will be the result when the following code is compiled and executed? final public class Parent { final public void test() { System.out.println("hello"); } } class Child extends Parent { //1 public void test() { //2 System.out.println("world"); } } class Main { public static void main(String args[]) { Child c = new Child(); c.test(); } }
inheritance
What will be the result of the following code execution? class Super { Super() { System.out.println("Super contructor"); } } public class Main extends Super { Main() { this(1); System.out.println("Main() contructor"); } Main(int i) { System.out.println("Main(int) contructor"); } public static void main(String [] args) { new Main(); } }
inheritance
How can a class inheritance be prohibited (top-level classes are considered)?
inheritance
Will this code compile? interface I1 {}; interface I2 extends I1{}; public class C implements I2, I1{}
inheritance
← Попередня
1
2
3
4
5
Наступна →
Зареєструйся Зараз
або
Підпишись на майбутні тести