Тести
Мова сайту: Українська
Українська
English
Русский
Тести з програмування
Вхід
Реєстрація
Тести з програмування
Теорія
Сніпети
Статті
Головна
Android
Ціни
FAQ
Історія Cosmo
Правила та умови сервісу
Політика конфіденційності
Політика щодо файлів cookie
Зворотній Зв’язок
clone
:
Мова контенту: English
Русский
What will be printed as a result of compiling and running the following code? public class Test { public static void main(String[] args) throws Exception { A a = new A(); a.setI(4); if (a instanceof Cloneable) { A a2 = (A) a.clone(); System.out.println(a.getI() == a2.getI()); } } } class A implements Cloneable { private int i; public void setI(int i) { this.i = i; } public int getI() { return i; } }
clone
What will be the result of compilation and execution of the following code? public class Test { public static void main(String[] args) { TestClone t1 = new TestClone(); TestClone t2 = (TestClone) t1.clone(); for(int i = 0; i < t2.arr.length; i++) { t2.arr[i] = (t2.arr.length - i); } System.out.println(t1.arr.equals(t2.arr)); } } class TestClone implements Cloneable { int arr[] = {1, 2, 3, 4, 5}; public Object clone() { try { return super.clone(); } catch(CloneNotSupportedException e) { System.out.println("Clone not supported"); return this; } } }
clone
← Попередня
1
Наступна →
Зареєструйся Зараз
або
Підпишись на майбутні тести