Thursday, October 7, 2010

IMportant POints in Java

Question :We can Call Main Method of one Class File from another Class.
Example :
Class DEMO(){
public static void main(String args[]){
S.o.p("sekhar");
}
}

Class DEMO2(){
Public static void main(String args[]){
DEMO.main("some argument");
}
}
1>When JVM calls the Main Method, it Executes it as Thread.
2>When We call the main Method it Executes it as Function.
Note : We can call main Method of a Class by Passing NULL as Argument.
But JVM does not call main Method as Null, Instead it Pass a Empty String Array as argument.

Question : What is the Difference between the compareTo Method and equals method in Java?
Answer :  equals method() : Check whether two strings are equal or not by content and true or false.
               compareTo method() : Check lexiographically returns the difference between the chars.
 Pitfalls :
               IF two names are same but represented in different languages then Equals method gives
               false.

No comments:

AWS certification question

AWS AWS Hi! this is for questions related to AWS questions. EC2 instances EC2 storage types cold HDD : 1. Defines performance in terms...