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 deprecated method stop() 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 "deprecated method stop()" Watch "deprecated method stop()" New topic
Author

deprecated method stop()

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
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.

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
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

Java Resources at www.wbrogden.com
 
 
subject: deprecated method stop()
 
Similar Threads
Thread
Majji - Paper 1
stop ()
Threads
Thread Stop.......