logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

  • Question
  • What is the difference between creating a thread by extending Thread class and by implementing Runnable interface? Which one should prefer?


  • Correct Answer
  • When creating a thread by extending the Thread class, it is not mandatory to override the run method (If we are not overriding the run method , it is useless), because Thread class have already given a default implementation for run method But if we are implementing Runnable , it is mandatory to override the run method The preferred way to create a thread is by implementing Runnable interface, because it give loose coupling 


  • Technology problems


    Search Results


    • 1. What are the the different ways for creating a thread?
    • Discuss
    • 2. How does a try statement determine which catch clause should be used to handle an exception?
    • Discuss
    • 3. What is static initializer block? What is its use?
    • Discuss
    • 4. What is the impact of declaring a method as final?
    • Discuss
    • 5. What is difference between Path and Classpath?
    • Discuss
    • 6. What is Thread ?
    • Discuss
    • 7. What do you understand by private, protected and public?
    • Discuss
    • 8. If a method is declared as protected, where may the method be accessed?
    • Discuss
    • 9. What is the difference between method overriding and overloading?
    • Discuss
    • 10. What is classloader?
    • Discuss


    Comments

    There are no comments.

Enter a new Comment