Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Threads

 
kiruthigha rajan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A. foo
B. MyThread foo
C. MyThread bar
D. foo bar
E. foo bar baz
F. bar foo
G. Compilation fails
H. An exception is thrown at runtime

the answer is B
in this code my doubts is:
1) how Mythread() is being executed?
thanks in advance
 
Nam Ha Minh
Ranch Hand
Posts: 504
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kiruthigha rajan wrote:[code=java]
1) how Mythread() is being executed?


Do you forget that it is the constructor? which is always invoked when a new object is created.
 
kiruthigha rajan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nam Ha Minh wrote:
kiruthigha rajan wrote:[code=java]
1) how Mythread() is being executed?


Do you forget that it is the constructor? which is always invoked when a new object is created.

oh ya thanks alot..how can i be so carlesss.anyways thanks alot
 
Henry Wong
author
Marshal
Pie
Posts: 21504
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
 
kiruthigha rajan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Please QuoteYourSources.

Henry


SCJP : K & B : page no. 778
 
Helen Ma
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. When MyThread constructor is called, it prints "MyThread".
2 . t is an object of MyThread's subtype. This object implements the overridden method run(). So, "foo" is printed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic