• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

deprecated method stop()

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everbody,
In the following code depricated function stop() is used.

public class Q1 extends Thread
{
public void run()
{
System.out.println("Before start method");
this.stop();
System.out.println("After stop method");
}
public static void main(String[] args)
{
Q1 a = new Q1();
a.start();
}
}

So if such type of question comes in exam what should be the output:
1. program uses a deprecated method
or
2.prints "Before start method
Thanks in advance
Shikhar
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by shikhar:
Hi everbody,
In the following code depricated function stop() is used.

public class Q1 extends Thread
{
public void run()
{
System.out.println("Before start method");
this.stop();
System.out.println("After stop method");
}
public static void main(String[] args)
{
Q1 a = new Q1();
a.start();
}
}

So if such type of question comes in exam what should be the output:
1. program uses a deprecated method
or
2.prints "Before start method
Thanks in advance
Shikhar


1 and 2. You can compile and run a program with deprecated methods! You get a deprecation warning at compile time but, this is a watning only! The program will still run.
Sun deprecates things for a lot of reasons. In most cases they either have a new method in the same or another class to replace it or (as in the case of stop()) a safe work around. These are still valid methods to allow backward compatability so old code doesn't have to be changed imediately but, be warned... They will remove it in a future release.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not heard of anybody getting a question that involved figuring out what code using a deprecated method would do when run. If anybody does, I would love to hear about it.
You may be expected to know that stop is deprecated, and it would enhance your general knowledge of Threads to know why stop, suspend, and resume are all deprecated.
Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic