-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
165 lines (136 loc) · 4.38 KB
/
Solution.java
File metadata and controls
165 lines (136 loc) · 4.38 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//that the word of Jesus might be fulfilled, which he spoke, signifying by what kind of death he should die (John 18:32)
package com.javarush.task.task19.task1928;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/*
Исправить ошибку. Классы и интерфейсы
*/
public class Solution {
{
System.out.println("it's Solution class");
}
public static void main(String... args) throws IOException {
try (
FileOutputStream outputStream = new FileOutputStream("c:/anyFile.txt");
InputStream is = Solution.class.getClassLoader().getResourceAsStream("/anyResource.jpg");
) {
;
byte[] b = new byte[is.available()];
outputStream.write(is.read(b));
int value = 123_456_789;
System.out.println(value);
Example result = null;
String s = "a";
switch (s) {
case "a": {
result = new Solution().new A();
break;
}
case "b": {
result = new Solution().new B();
break;
}
case "c": {
result = new Solution().new C();
break;
}
}
if (result instanceof C) {
C p = (C) result;
System.out.println(p.getClass().getSimpleName());
}
} catch (IOException e) {
}
}
interface Example {
}
class A implements Example {
{
System.out.println("it's A class");
}
}
class B implements Example {
{
System.out.println("it's B class");
}
}
class C extends A {
{
System.out.println("it's C class");
}
}
}
/*
Исправить ошибку. Классы и интерфейсы
Программа содержит всего 1 логическую ошибку.
Найди и исправь ее.
Требования:
1. Класс Solution должен содержать интерфейс Example.
2. Класс Solution должен содержать класс A который реализует интерфейс Example.
3. Класс Solution должен содержать класс B который реализует интерфейс Example.
4. Класс Solution должен содержать класс C который наследуется от класса A.
5. Исправь всего одну логическую ошибку.
package com.javarush.task.task19.task1928;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
*
Исправить ошибку. Классы и интерфейсы
*
public class Solution {
{
System.out.println("it's Solution class");
}
public static void main(String... args) throws IOException {
try (
FileOutputStream outputStream = new FileOutputStream(args[0]);
InputStream is = Solution.class.getClassLoader().getResourceAsStream(args[1]);
) {
;
byte[] b = new byte[is.available()];
outputStream.write(is.read(b));
int value = 123_456_789;
System.out.println(value);
Example result = null;
String s = "a";
switch (s) {
case "a": {
result = new Solution().new A();
break;
}
case "b": {
result = new Solution().new B();
break;
}
case "c": {
result = new Solution().new C();
break;
}
}
if (result instanceof A) {
C p = (C) result;
System.out.println(p.getClass().getSimpleName());
}
} catch (IOException e) {
}
}
interface Example {
}
class A implements Example {
{
System.out.println("it's A class");
}
}
class B implements Example {
{
System.out.println("it's B class");
}
}
class C extends A {
{
System.out.println("it's C class");
}
}
}
*/