• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Why this code not giving compile time error?

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Why the following code not giving the compile time error, please explain anyone?


Source: Certified java programmers exam question of the day(eXamulator).

Thanks in advance.
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
why should it give error? what thing wrong you find in this.
its more of a OOPS concept based question than on Threads..
you are implementing an interface and extending a class..
and you are not implementing run() method, you are overriding run method of Thread class and moreover if you don't explicitly say implementing Runnable, even then implicitly it implements Runnable.

see the following:

interface AI{
void m1();
}
class AImp implements AI{
public void m1(){}
}
class BImp extends AImp implements AI{
public void m1(){}
}
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not a compile-time error. But at runtime you will get an IllegalMonitorStateException because you are not calling the wait() method in a synchronized context.
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic