Why do I have access to the getName() method? My class doesn't extends the class Thread just implements the interface Runnable.
public class MyThread implements Runnable { public void run() { System.out.println("MyThread is running"); } public static void main(String[] args){ MyThread thread1 = new MyThread(); Thread thr = new Thread(thread1, "thread"); thr.start(); System.out.println(thr.currentThread().getName()); System.out.println(thr.getName());//Why do I have access to this method? } }