Kalidas Pavi

Ranch Hand
+ Follow
since Nov 20, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Kalidas Pavi

Varun,
The statement import java.awt.*; imports all classes defined in awt package. The packages (sub) defined inside the awt package are not imprted with this statement.
If you want to access the classes defined in any sub package then you require the second statement. The statement you specified imports all classes defined in the package event which is defined in the awt pakage.
Kalidas
24 years ago
Thanks, Marilyn.
24 years ago
I have submitted assignment 1.1 7 times and got it back again in first week of december and was not able to send it back as I was tied up at work. Can I start re-sending the assignment again from where it was stopped??? Please advise.
Regards,
Kalidas
24 years ago
Dharini,
The JLS requires main to be declared like this
public static void main(String[] args)
It works fine with private also, but for the purposes of certification (SCJP2) it is better to assume that the correct signature is as specified above.
Kalidas.
24 years ago
You are right.
The constructor for gridlayout is GridLayout(int rows, int cols)
Kalidas.
this story will give you an insight of what polymorphism is all about.
Kalidas.
[This message has been edited by Kalidas Pavi (edited January 20, 2001).]
Static variables are variables which can be accessed without instantiation.
Instance variables are variables which can be accessed only after instantiation.
Static variables are declared with the static modifier.
eg: public static mystat
Static variables are also called class variables as the static variables share the same memory location for all instances of the class.
Start reading a java book.
Kalidas.
See this to meet a 100% scorer!
24 years ago
Jim,
This means that main thread cannot be made Daemon???
Kalidas
I tried to make the main thread Daemon with the following code
public class MyThread {
public static void main(String[] args)
{
Thread t = Thread.currentThread(); // returns the main thread
t.setDaemon(true); //will throw illegal thread state exception
}}
This program compiles without any glitch, but it throws a run time exception IllegaThreadStateException. setDaemon(true) is not allowed for main thread.
Need some more light from the experts out there!!
Kalidas.
Agreed 2.
Methods can be considered as the counterparts of functions of procedural languages. Methods operates upon the data (fields) of a class and hence defines the behaviour of the class.
Kalidas
Why would you want to define a main method as Daemon??
Further main is given a special treament by JVM as it is the method JVM looks for in an application to execute after the class initializations are done.
I think we are not allowed to change the properties of the main method.
Kalidas
There is at least one instance when you must implement runnable instead of inheriting the thread class.
When you are witing an applet inheriting the applet class ie MyClass extends Applet, you can't say Myclass extends Applet extends Thread since JAVA do not support multiple inheritence.
You must implement the runnable interface in this case. ie MyClass extends Applet implements Runnable.
Kalidas
hi ganshre,
JVM treats threads as either non Daemon user threads or Daemon threads. A thread can be set to Daemon status by
1. Using the method setDaemon(true) before the thread is started via start() method call.
2. When a Daemon thread creates a new thread the new thread automatically inherits the Daemon status of its parent thread. In this case a setDaemon(true) call is not required for making the thread Daemon.In other words, all threads created by Daemon threads will be Daemonss!!!
When an application is started, the main method thread is executed as a user thread and if there are no other user threads created by the main method the application will exit once the main method thread is completed.
If JVM finds out that only Daemon threads are running in the application, (ie all the user threads are stopped) JVM will close down the application and exit.
The main advantage of Daemon threads are that they are automatically killed by the JVM once no other threads are existing. We don't need to worry about stopping the Daemon threads. But be careful not to assign any important tasks in Daemon threads as Daemons may end abruptly without your consent once all other threads are stopped and thereby creating havoc.
Hope I have made it somewhat clear...
Kalidas.
try this
for ( int i = 0; i<=100; i=i+10)
g.drawString("Print Something",10,20+i);
Kalidas
24 years ago