Author Archives: Stanislav_Panteleev

Java.Core.What is the difference between checked and unchecked exceptions?

Difference Between Checked and Unchecked Exceptions in Java Exceptions in Java are categorized into checked and unchecked exceptions based on whether the compiler enforces handling.

Posted in Без рубрики | Comments Off on Java.Core.What is the difference between checked and unchecked exceptions?

Java.Core.What is a checked and unchecked exception?

In Java, exceptions are classified into checked and unchecked exceptions based on whether the compiler forces handling at compile time.

Posted in Без рубрики | Comments Off on Java.Core.What is a checked and unchecked exception?

Java.Core.What types of exceptions in Java do you know, how do they differ?

Types of Exceptions in Java & Their Differences In Java, exceptions are categorized based on their recoverability and handling requirements. The main types are: Checked Exceptions (Compile-time exceptions) Unchecked Exceptions (Runtime exceptions) Errors (Serious system-level issues)

Posted in Без рубрики | Comments Off on Java.Core.What types of exceptions in Java do you know, how do they differ?

Java.Core.Philosophy behind checked and unchecked exceptions

1. Philosophy Behind Checked vs. Unchecked Exceptions Checked Exceptions (IOException, SQLException, etc.) Represent recoverable conditions that are beyond the developer’s control. The compiler forces handling to prevent errors at runtime. Example: File not found, network failure, database connection issues. Unchecked … Continue reading →

Posted in Без рубрики | Comments Off on Java.Core.Philosophy behind checked and unchecked exceptions

Java.Core.Describe the hierarchy of exceptions

Java provides a structured exception handling mechanism based on an inheritance hierarchy. At the top, all exceptions and errors are subclasses of Throwable, which is further divided into Exception and Error. Top-Level Hierarchy

Posted in Без рубрики | Comments Off on Java.Core.Describe the hierarchy of exceptions

Java.Core.Why Try-with-resources (try with AutoCloseable) is a better alternative to finally for resource

In Java, try-with-resources (introduced in Java 7) is a more elegant and reliable way to manage resources like file streams, sockets, and database connections compared to using finally. It ensures that resources are closed automatically, reducing boilerplate code and eliminating … Continue reading →

Posted in Без рубрики | Comments Off on Java.Core.Why Try-with-resources (try with AutoCloseable) is a better alternative to finally for resource

Java.Core.How does Java handle exceptions with try-catch-finally?

In Java, exceptions are handled using the try-catch-finally construct, which allows developers to manage errors gracefully and prevent abrupt program termination. Here’s how it works:

Posted in Без рубрики | Comments Off on Java.Core.How does Java handle exceptions with try-catch-finally?

Java.Collections.Why Do Keys with Different Hash Codes End Up in the Same Bucket in a HashMap?

Yes, I know! In HashMap (and other hash-based data structures), keys with different hash codes can end up in the same bucket due to the mechanics of hashing and bucket indexing. Why Does This Happen? The Bucket Array Has a … Continue reading →

Posted in Без рубрики | Comments Off on Java.Collections.Why Do Keys with Different Hash Codes End Up in the Same Bucket in a HashMap?

Java.Core.There is a class Point{int x, y;}. Why is a hash code of the form 31 * x + y preferable to x + y?

🚀 Why Is 31 * x + y Preferable to x + y for hashCode() in a Point Class? When implementing hashCode(), 31 * x + y is preferred over x + y because it produces better hash distribution, reducing … Continue reading →

Posted in Без рубрики | Comments Off on Java.Core.There is a class Point{int x, y;}. Why is a hash code of the form 31 * x + y preferable to x + y?

Java.Core.Is it possible to implement the equals() method of the MyClass class like this: class MyClass {public boolean equals(MyClass that) {return this == that;}}?

1️⃣ Why Is This Implementation Wrong? ❌ Incorrect equals() Implementation 📌 Problems: Does Not Override Object.equals(Object) Java does not recognize this as an override because the method signature must be equals(Object that). It is a separate method, not an actual … Continue reading →

Posted in Без рубрики | Comments Off on Java.Core.Is it possible to implement the equals() method of the MyClass class like this: class MyClass {public boolean equals(MyClass that) {return this == that;}}?