Interfaces
- What is the correct option with regards to below snippet?
interface NewCustomer
{
}
class RegCustomer implements NewCustomer
{
}
class QuickCustomer implements NewCustomer
{
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
According to Liskov substitution principle we can replace NewCustomer with RegCustomer or QuickCustomer without affecting functionality.
- Autocloseable was introduced in which Java version?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Java 7 introduced autocloseable interface.
- What is the alternative of using finally to close resource?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Autocloseable interface provides close() method to close this resource and any other underlying resources.
- Which of the below is a child interface of Autocloseable?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
A closeable interface extends autocloseable interface. A Closeable is a source or destination of data that can be closed.
- It is a good practise to not throw which exception in close() method of autocloseable?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
InterruptedException interacts with a thread’s interrupted status and runtime misbehavior is likely to occur if an InterruptedException is suppressed.