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