We have two methods to create methods the threads.
1. Implementing runnable interface
2. Extending to thread class and overriding run method.
Among these two which one is better and why?
Please explain me in detail.
Answer Posted / venkat
implementing runnable interface is better than extending to
thread why because if u implements from runnable interface u
can have chance to extend one more class.but incase of
extending thread this facility is not there
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
Explain the use of shift operator in java. Can you give some examples?
What are basic keywords?
What is main method?
Are private methods final?
What is the method to declare member of a class static?
Tell us something about different types of casting?
Is static variable stored in heap?
What is string immutability?
How do you create an array in java?
1.IN CASE OF DYNAMIC METHOD DISPATCH WHY WE USE REFERENCE VARIABLE,WE CAN USE THE DIFFERENT DEFINED OBJECT DIRECTLY TO ACCESS THE DATA MEMBER AND MEMBER FUNCTION OF THAT RESPECTIVE CLASS?WHAT IS THE MAIN FUNCTION OF "REFERENCE VARIABLE" HERE?
Define how can we find the actual size of an object on the heap?
What is the difference between pass by reference and pass by pointer?
If a method is declared as protected, where may the method be accessed?
How a string is stored in memory?
Is vector synchronized in java?