lr13 -> task_1 -> e1-e14

This commit is contained in:
2026-05-23 16:50:10 +05:00
parent 7310b240fd
commit 7c4e17e1b1
14 changed files with 230 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
package lr13.task_1;
public class e1 {
public static void main(String[] args) {
try {
System.out.println("0");
throw new RuntimeException("Непроверяемая ошибка");
} catch (RuntimeException e) { // исключение перехвачено
System.out.println("1 " + e); // исключение обработано
}
System.out.println("2");
}
}
+17
View File
@@ -0,0 +1,17 @@
package lr13.task_1;
public class e10 {
public static int m() {
try {
System.out.println("0");
return 15;
} finally {
System.out.println("1");
return 20;
}
}
public static void main(String[] args) {
System.out.println(m());
}
}
+15
View File
@@ -0,0 +1,15 @@
package lr13.task_1;
public class e11 {
public static void main(String[] args) {
try {
System.out.println("0");
throw new NullPointerException("ошибка");
} catch (NullPointerException e) {
System.out.println("1");
} finally {
System.out.println("2");
}
System.out.println("3");
}
}
+20
View File
@@ -0,0 +1,20 @@
package lr13.task_1;
public class e12 {
public static void m(String str, double chislo) {
try {
if (str == null) {
throw new IllegalArgumentException("Строка введена неверно");
}
if (chislo > 0.001) {
throw new IllegalArgumentException("Неверное число");
}
} catch (IllegalArgumentException e) {
System.out.println("Error: " + e);
}
}
public static void main(String[] args) {
m(null, 0.000001);
}
}
+17
View File
@@ -0,0 +1,17 @@
package lr13.task_1;
public class e13 {
public static void main(String[] args) {
try {
int l = args.length;
System.out.println("размер массива = " + l);
int h = 10 / l;
args[l + 1] = "10";
} catch (ArithmeticException e) {
System.out.println("Деление на ноль");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Индекс не существует");
}
}
}
+17
View File
@@ -0,0 +1,17 @@
package lr13.task_1;
public class e14 {
public static void m(int x) throws ArithmeticException {
int h = 10 / x;
}
public static void main(String[] args) {
try {
int l = args.length;
System.out.println("размер массива = " + l);
m(l);
} catch (ArithmeticException e) {
System.out.println("Ошибка: Деление на ноль");
}
}
}
+14
View File
@@ -0,0 +1,14 @@
package lr13.task_1;
public class e2 {
public static void main(String[] args) {
try {
System.out.println("0");
throw new RuntimeException("Непроверяемая ошибка");
// System.out.println("1");
} catch (Exception e) {
System.out.println("2 " + e);
}
System.out.println("3");
}
}
+17
View File
@@ -0,0 +1,17 @@
package lr13.task_1;
public class e3 {
public static void main(String[] args) {
try {
System.out.println("0");
throw new RuntimeException("ошибка");
} catch (NullPointerException e) {
System.out.println("1");
} catch (RuntimeException e) {
System.out.println("2");
} catch (Exception e) {
System.out.println("3");
}
System.out.println("4");
}
}
+17
View File
@@ -0,0 +1,17 @@
package lr13.task_1;
public class e4 {
public static void main(String[] args) {
try {
System.out.println("0");
throw new RuntimeException("ошибка");
} catch (NullPointerException e) {
System.out.println("1");
} catch (Exception e) {
System.out.println("2");
} catch (Error e) {
System.out.println("3");
}
System.out.println("4");
}
}
+13
View File
@@ -0,0 +1,13 @@
package lr13.task_1;
public class e5 {
public static void main(String[] args) {
try {
System.out.println("0");
throw new RuntimeException("ошибка");
} catch (RuntimeException e) {
System.out.println("1");
}
System.out.println("2");
}
}
+15
View File
@@ -0,0 +1,15 @@
package lr13.task_1;
public class e6 {
public static void main(String[] args) {
try {
System.out.println("0");
throw new NullPointerException("ошибка");
} catch (ArithmeticException e) {
System.out.println("1");
} catch (Exception e) {
System.out.println("2");
}
System.out.println("4");
}
}
+18
View File
@@ -0,0 +1,18 @@
package lr13.task_1;
public class e7 {
public static void main(String[] args) {
try {
System.out.println("0");
throw new NullPointerException("ошибка");
} catch (NullPointerException e) {
System.out.println("1");
try {
throw new ArithmeticException();
} catch (ArithmeticException e2) {
System.out.println("2");
}
}
System.out.println("3");
}
}
+19
View File
@@ -0,0 +1,19 @@
package lr13.task_1;
public class e8 {
public static int m() {
try {
System.out.println("0");
throw new RuntimeException();
} catch (RuntimeException e) {
System.out.println("1");
} finally {
System.out.println("2");
}
return 3;
}
public static void main(String[] args) {
System.out.println(m());
}
}
+17
View File
@@ -0,0 +1,17 @@
package lr13.task_1;
public class e9 {
public static int m() {
try {
System.out.println("0");
return 55; // выход из метода
} finally {
System.out.println("1");
}
}
public static void main(String[] args) {
System.out.println(m());
}
}