Computer Science, asked by AnujMalik489, 11 months ago

What is the method that a non abstract class implementing runnable interface should implement?

Answers

Answered by Anonymous
2

Answer:

The answer will be run()

Below is an example of using run()

import java.io.FileNotFoundException;  

  public class ThredTest {  

   public static void main(String[] args)  

   {  

       System.out.println("Main thread ::- " +  

                         Thread.currentThread().getName());  

       Thread t = new Thread(new ThreadTest().new ThreadShow());  //instance of a Thread in created

       t.start();  

   }  

 

   private class ThreadShow implements Runnable {  

 

       public void run()  //implementing run()

       {  

           System.out.println(Thread.currentThread().getName()  

                            + ", executing run() method!");  

           try {  

               throw new FileNotFoundException();  

           }  

           catch (FileNotFoundException e) {  

               System.out.println("Must catch here!");  

               e.printStackTrace();  

           }  

 

           int r = 1 / 0;  

         

           }  

   }  

}

Similar questions