Самые популярные вопросы и ответы для интервью и онлайн-тесты
Образовательная платформа для подготовки к интервью, онлайн-тестов, учебных материалов и живой практики

Развивайте навыки с целевыми маршрутами обучения, пробными тестами и контентом для подготовки к интервью.

WithoutBook объединяет вопросы для интервью по предметам, онлайн-практику, учебные материалы и сравнительные руководства в одном удобном учебном пространстве.

Подготовка к интервью

Java Exception Handling вопросы и ответы для интервью

Вопрос 11. Explain the difference between 'throw' and 'throws' in Java.

'throw' is used to explicitly throw an exception, while 'throws' is used in method signature to declare that the method may throw one or more types of exceptions.

Это полезно? Добавить комментарий Посмотреть комментарии
 

Вопрос 12. What is the purpose of the 'NullPointerException' in Java?

The 'NullPointerException' is thrown when attempting to access or modify an object reference that is null.

Example:

String str = null;
int length = str.length(); // This will throw NullPointerException

Это полезно? Добавить комментарий Посмотреть комментарии
 

Вопрос 13. How can you create a custom exception in Java?

To create a custom exception, you need to extend the 'Exception' class or one of its subclasses.

Example:

class CustomException extends Exception { /* constructor and additional code */ }

Это полезно? Добавить комментарий Посмотреть комментарии
 

Вопрос 14. What is the purpose of the 'try' block?

The 'try' block is used to enclose a block of code where exceptions might occur.

Example:

try { /* code that may throw exceptions */ } catch (Exception e) { /* handle exception */ }

Это полезно? Добавить комментарий Посмотреть комментарии
 

Вопрос 15. Can you have multiple 'finally' blocks in a try-catch-finally statement?

No, there can be at most one 'finally' block associated with a 'try-catch' statement.

Это полезно? Добавить комментарий Посмотреть комментарии
 

Самое полезное по оценкам пользователей:

Авторские права © 2026, WithoutBook.