Тести
Мова сайту: Українська
Українська
English
Русский
Тести з програмування
Вхід
Реєстрація
Тести з програмування
Теорія
Сніпети
Статті
Головна
Android
Ціни
FAQ
Історія Cosmo
Правила та умови сервісу
Політика конфіденційності
Політика щодо файлів cookie
Зворотній Зв’язок
static keyword
:
Мова контенту: English
Русский
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(); } }
static keyword
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(); } }
static keyword
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"; } }
static keyword
What happens as a result of compiling and running the following code: public class Bar extends Foo { // 1 public static void main(String[] args) { // 2 System.out.print(sum(1, 2)); // 3 } } class Foo { int sum(int x, int y) { return x + y; } }
static keyword
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); } }
static keyword
What will be brought up in the console? public class Test { { System.out.println("1"); } Test () { System.out.println("2"); } static { System.out.println("3"); } { System.out.println("4"); } public static void main(String[] args) { new Test(); } }
static keyword
There are two classes that are declared in the file. That will be displayed after the launch? Test.java: class Singleton { private static Singleton s = new Singleton(); protected Singleton() { System.out.println("S"); } public static Singleton getInstance() { return s; } } public class Test { public void method() { Singleton.getInstance(); } public static void main(String [] str) { new Test(); } }
static keyword
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(); } }
static keyword
How to change the location labeled //1 for code to compile? public class Test { public static void main(String s[]) { int i = getX(); } private int getX() { //1 return 10; } }
static keyword
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()"); } }
static keyword
← Попередня
1
2
3
4
5
Наступна →
Зареєструйся Зараз
або
Підпишись на майбутні тести