Looking for Об'єктно-орієнтоване програмування test answers and solutions? Browse our comprehensive collection of verified answers for Об'єктно-орієнтоване програмування at virt.ldubgd.edu.ua.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Результат компіляції програми:
public class MultipleCatches {
public static void main(String[] args) {
try {
int a = 1;
int b = 2 / a;
int c[] = new int [1];
c[2] = 5;
} catch (ArithmeticException e) {
System.out.println("Ділення на нуль: ");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Помилка індексації за межами масиву: ");
}
System.out.println("Після блоку операторів try/catch");
}
}Результат компіляції програми:
public class FinallyDemo {
static void A() {
try {
System.out.println("В тілі методу A()");
} finally {
System.out.println("Виконання finally в методі A()");
}
}
static void B() {
try {
System.out.println("В тілі методу В()");
return;
} finally {
System.out.println("Виконання finally в методі B()");
}
}
public static void main(String[] args) {
A();
B();
}
}Для чого служить блок оператора try під час опрацювання виключень?
Для чого служить блок оператора catch під час опрацювання виключень?