why Runnable interface is preferable than extending the
Thread class?

Answers were Sorted based on User's Feedback



why Runnable interface is preferable than extending the Thread class?..

Answer / suresh

u know that java not supporting multiple inheritance.if u
extend thread class,u can't extend any class which you
required other than thread class.if u are implementing
runnable interface u can extend any class which you required
other than thread class.this is main advantage of
implementing runnable interface.

Is This Answer Correct ?    115 Yes 13 No

why Runnable interface is preferable than extending the Thread class?..

Answer / susheeel

Many Java programmers feel that classes should be extended
only when they are enhanced or modified in some way.So,if
you will not be overriding any of Thread's other methods,it
is probably best simply to implement Runnable.

Is This Answer Correct ?    32 Yes 5 No

why Runnable interface is preferable than extending the Thread class?..

Answer / amit singh

is this prefable why simple
you class A extends other class B
and it also want to be a thread then what you should
beacuse its allow in java that one class extends two class
its not possible in java
class A
{
}
class B extends A
{
}
then what to do to make the thread of class B
so you are going to extends the Thread class too
its biggest blunder in java so you should to prefer
implements the Runnable interface
that it not just the f--k above mention though my ther frnds
thanks imagie
class B extends A implements Runnable
{
public void run()
{
}

}
class C
{
public static void main(String []args)
{
C c = new C();
B b = new B();
Thread t1 = new Thread(b);
t1.start();
}
}
}
and another reason to implements the Runnable interface
when you want to allocate some specific work means to say
that you just whe the thead will create and run ,through the
run method which you define in this class do some
when the thread runs means to say that when you extends
Thread and you not define the run method the default will
run
and when you implements the Runnable you must and needs to
define it do some functionaklity on each thread creation
thanks amitsing2008@gmail.com
amit09mca

Is This Answer Correct ?    11 Yes 3 No

why Runnable interface is preferable than extending the Thread class?..

Answer / rameshkrishna

imolimen Runnabule inerface and extends Thread functionally
both are same.But implimenting RunnebleInterface more
advantage because of there is possibility extends more then
one class and also we can override run() only once.

Is This Answer Correct ?    10 Yes 4 No

why Runnable interface is preferable than extending the Thread class?..

Answer / praveen gupta

The main reason to implement Runnable interface is that you know that java does not supporting multiple inheritance
through classes .if u extend Thread class,u can't extend any
class which you required other than thread class.if u are
implementing runnable interface u can extend any class which
you required other than thread class.this is main advantage of
implementing java.lang.Runnable interface.

Is This Answer Correct ?    4 Yes 0 No

why Runnable interface is preferable than extending the Thread class?..

Answer / srinu

you know that java does not supporting multiple inheritance
through classes .if u extend Thread class,u can't extend any
class which you required other than thread class.if u are
implementing runnable interface u can extend any class which
you required other than thread class.this is main advantage of
implementing java.lang.Runnable interface.

Is This Answer Correct ?    6 Yes 3 No

why Runnable interface is preferable than extending the Thread class?..

Answer / myluvdeepu

if we extend thread then we can't extend other class.
but if we implement runnable interface we can implement as much interface as we can, there is no restriction.

thread call the run method automatically(if called with no-arg).but for runnable we need to call run method.
thread cause problem in multiple inheritance.
but runnable interface don't.

Is This Answer Correct ?    4 Yes 9 No

Post New Answer

More Core Java Interview Questions

what is the difference between process and thread? : Java thread

0 Answers  


What are the benefits of operations?

0 Answers  


What is java algorithm?

0 Answers  


Can I use % with real numbers?

0 Answers  


Is string a keyword in java?

1 Answers  






Program to Find the second largest element in an array.

0 Answers   Amazon,


How to run a JAR file through command prompt?

0 Answers  


explain how many oops concepts available in java with realtime scenarios?

1 Answers   TCS,


How many bytes is double?

0 Answers  


why java does not have operator overloading?

2 Answers  


Does 'true' and 'false' are keywords?

5 Answers  


You're given a Boolean 2D matrix, can you find the number of islands?

0 Answers   Amazon,


Categories