64. What is the purpose of the "try-with-resources" statement in Java?
The "try-with-resources" statement in Java is used to automatically close resources
that implement the "AutoCloseable" interface. It ensures that resources, such as file
streams or database connections, are properly closed, even if an exception occurs.
65. What is the purpose of the "instanceof" operator in Java?
The "instanceof" operator in Java is used to check whether an object is an instance of a
specific class or implements a specific interface. It returns a boolean value indicating
the result of the check.
66. What is the difference between the pre-increment and post-increment operators?
The pre-increment operator (++i) in Java increments the value of a variable and returns
the incremented value, while the post-increment operator (i++) increments the value
of a variable but returns the original value before the increment.
67. What is the difference between the pre-decrement and post-decrement
operators?
The pre-decrement operator (--i) in Java decrements the value of a variable and returns
the decremented value, while the post-decrement operator (i--) decrements the
value of a variable but returns the original value before the decrement.
68. What is the purpose of the "Math" class in Java?
The "Math" class in Java provides various methods for performing common
mathematical operations, such as square roots, trigonometric functions, exponential
calculations, rounding, and more.
69. What is the purpose of the "StringBuffer" class in Java?
The "StringBuffer" class in Java is used to create and manipulate mutable sequences of
characters, similar to the "StringBuilder" class. However, "StringBuffer" is synchronized
Dostları ilə paylaş: |