Skip to content

Commit 0d28567

Browse files
authored
I thank God
I thank God that I baptized none of you, but Crispus and Gaius (1Cor 1:14)
1 parent dd50cb9 commit 0d28567

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
//I thank God that I baptized none of you, but Crispus and Gaius (1Cor 1:14)
3+
4+
package com.javarush.task.task24.task2402;
5+
6+
/*
7+
Cloneable
8+
*/
9+
public class Solution {
10+
11+
public static void main(String[] args) throws CloneNotSupportedException {
12+
Test1 test1 = new Test1();
13+
test1.clone();
14+
15+
Test2 test2 = new Test2();
16+
test2.clone(new Test2());
17+
18+
Test3 test3 = new Test3();
19+
test3.c1one();
20+
21+
Test4 test4 = new Test4();
22+
test4.clone();
23+
}
24+
25+
26+
public static class Test1 implements Cloneable{
27+
protected Test1 clone() throws CloneNotSupportedException {
28+
return (Test1)super.clone();
29+
}
30+
}
31+
32+
public static class Test2 extends Test1 {
33+
public Test2 clone(Test2 test2) throws CloneNotSupportedException {
34+
return (Test2)test2.clone();
35+
}
36+
}
37+
38+
public static class Test3 {
39+
protected Object c1one() throws CloneNotSupportedException {
40+
return new Test3();
41+
}
42+
}
43+
44+
public static class Test4 extends Test3 implements Cloneable {
45+
@Override
46+
protected Object clone() throws CloneNotSupportedException {
47+
return super.clone();
48+
}
49+
}
50+
}
51+
52+
/*
53+
Cloneable
54+
Добавьте java-код, чтобы метод main отработал без исключений.
55+
56+
57+
Требования:
58+
1. Класс Test4 должен поддерживать интерфейс Cloneable.
59+
2. В классе Test4 должен быть реализован метод clone() без параметров.
60+
3. В методе main должен быть вызван метод clone на объекте типа Test1.
61+
4. В методе main должен быть вызван метод clone на объекте типа Test2.
62+
5. В методе main должен быть вызван метод clone на объекте типа Test4.
63+
6. В методе main должен быть вызван метод c1one на объекте типа Test3.
64+
7. Класс Test1 должен поддерживать интерфейс Cloneable.
65+
66+
*/

0 commit comments

Comments
 (0)