aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads: question from jchq Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads: question from jchq" Watch "Threads: question from jchq" New topic
Author

Threads: question from jchq

madhu v pe
Ranch Hand

Joined: Apr 21, 2007
Posts: 100
Hi,

the answer is
3) Compile time error: class Runt is an abstract class. It can't be instantiated.

my doubt is why Runt is abstrct class?

Thanks
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
Hi.

Because if a class implements interface Runnable it must override the abstract method run().
[ May 15, 2007: Message edited by: Leandro Melo ]

Leandro Melo
SCJP 1.4, SCWCD 1.4
madhu v pe
Ranch Hand

Joined: Apr 21, 2007
Posts: 100
Melo,
Thanks for your reply.
so, if any class implementing an interface and not providing functionality of the methods will be considered as abstract class.
am I right?

Thanks
Meena R. Krishnan
Ranch Hand

Joined: Aug 13, 2006
Posts: 178

if any class implementing an interface and not providing functionality of the methods will be considered as abstract class.


Instead, look at it this way,
Only an abstract class can skip the implementation of the Interface's methods that it is extending.

In the sample, the compilation error you will get is
"The type Runt must implement the inherited abstract method Runnable.run()"


Either the given answer options are insufficient or the answer C) needs to be reworded.
madhu v pe
Ranch Hand

Joined: Apr 21, 2007
Posts: 100
Thanks krishnan, for posting another way of understanding the answer.

we will leave the options given in the question, lets concentrate on the appropriate answer.

Originally posted by M Krishnan:

In the sample, the compilation error you will get is
"The type Runt must implement the inherited abstract method Runnable.run()"


when I compile it says - "Runt is not abstract and does not override abstract method run() in java.lang.Runnable"

as you mentioned above there is no question of inheritance right?
If I misunderstood or still need to go depth of your answer pls clarify me.

Thanks
[ May 17, 2007: Message edited by: madhu v pe ]
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
It's not that if a class implements an interface and does not provide it's method/s implementation you can get away with the class if you do not instatiate the class. For exaple if you remove these line

You still would not be able to compile the code because you need to either mark the class as explicitly abstract or provide an implementation for the interface method/s.

A class would not automatically become abstract if you do not provide the implementation for the interface method/s. Hence I would say all possible answers are infact wrong.
[ May 17, 2007: Message edited by: Anupam Sinha ]
madhu v pe
Ranch Hand

Joined: Apr 21, 2007
Posts: 100
Yes Anupam,

you are right. probably answer 3 is also not exactly correct with the wording. what me and krishnan agreed before.
the correct reason will be
1.since Runt is implementing Runnable it should provide the implementation of its methods which is run()
2 otherwise Runt should be declared as abstract.

Am I right?

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads: question from jchq
 
Similar Threads
Thread doubt?
is this Ambiguous?
about thread
Marcus Green: incorrect answer?
Runnable interface question from Marcus tutorial