Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Given: ...

 
Folkert Meeuw
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What is the result ?
(A) Cat
(B) Dog
(C) Compilation fails
(D) The code runs with no output
(E) An exception is thrown at runtime
 
Dejan Miler
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have typing mistake on line 12.

Dejan.

 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


why does this give me compile error that Thread(Runnable) can not be found....
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folkert please Use A Meaningful Subject Line when you start a topic.

Also you have to Quote Your Sources when you post a question.
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone???
 
Henry Wong
author
Marshal
Pie
Posts: 20894
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur kothari wrote:why does this give me compile error that Thread(Runnable) can not be found....


Compiles fine for me -- eclipse using Java 5.

Henry
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Please, please, please indent your code

You should do it for yourself, so that you'll have an easier time debugging stuff.
You should do it so that when you show your code to other people they won't be tempted to poke your eyes out.
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am compiling from command....there is a compile error that Thread(Runnable) constructor.....cannot find symbol with location java.lang.Thread
 
Punit Singh
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur kothari wrote:anyone???


I am not getting this error.
 
Henry Wong
author
Marshal
Pie
Posts: 20894
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur kothari wrote:i am compiling from command....there is a compile error that Thread(Runnable) constructor.....cannot find symbol with location java.lang.Thread



Can you show us the full error listing?

Henry
 
Dejan Miler
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe he have another Thread class in that package
 
Punit Singh
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur kothari wrote:i am compiling from command....there is a compile error that Thread(Runnable) constructor.....cannot find symbol with location java.lang.Thread


I am not getting error from the command line also.
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cannot find symbol at line 12
symbol: constructor Thread(Runnable)
location: java.lang.Thread
Thread t=new Thread(r);
^
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey but the code works when i compile it from someother directory
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have cheecked everything...no thread.class in this directory
 
Henry Wong
author
Marshal
Pie
Posts: 20894
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Did you happen to create your own Runnable class or interface?

Henry
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
genius...i had Runnable.class..its compiling now
 
Kedar Sarmalkar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folkert Meeuw wrote:
What is the result ?
(A) Cat
(B) Dog
(C) Compilation fails
(D) The code runs with no output
(E) An exception is thrown at runtime


C - If there is mistake on line 12
D - If you fix line 12 and If you do not call t.start();
B - If you fix line 12 and If t.start() is called, because the anonymous class created overrides the run method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic