File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Regarding Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Regarding Threads" Watch "Regarding Threads" New topic
Author

Regarding Threads

kiruthigha rajan
Ranch Hand

Joined: Dec 29, 2011
Posts: 69

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

Joined: Oct 31, 2011
Posts: 484

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.


PM Me If You Want to get Urgent Help on Java Programming
kiruthigha rajan
Ranch Hand

Joined: Dec 29, 2011
Posts: 69
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
Sheriff

Joined: Sep 28, 2004
Posts: 18101
    
  39


Please QuoteYourSources.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
kiruthigha rajan
Ranch Hand

Joined: Dec 29, 2011
Posts: 69
Henry Wong wrote:
Please QuoteYourSources.

Henry


SCJP : K & B : page no. 778
Helen Ma
Ranch Hand

Joined: Nov 01, 2011
Posts: 451
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding Threads
 
Similar Threads
Question on therad k&b 739 q.14
Mixing Inner class and Thead
special 'rule' ?
threads query
a threads question