Interfaces


  1. What is the correct option with regards to below snippet?
    interface NewCustomer 
    {
    }
    class RegCustomer implements NewCustomer
    {
    }
    class QuickCustomer implements NewCustomer
    {
    }











  1. 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.


  1. Autocloseable was introduced in which Java version?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Java 7 introduced autocloseable interface.



  1. What is the alternative of using finally to close resource?











  1. 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.


  1. Which of the below is a child interface of Autocloseable?











  1. 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.



  1. It is a good practise to not throw which exception in close() method of autocloseable?











  1. 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.