Q:
         
         
            
               What is the difference between creating a thread by extending Thread class and by implementing Runnable interface? Which one should prefer?
            
                      
         
             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.
          
         
         
         
             View answer
             Workspace
             Report Error
             Discuss