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.