in a console we r giving java <class name> if r pressing
enter where it'll goes
Answers were Sorted based on User's Feedback
Answer / srujan jack
it transfers the class name to JVM then the JVM calls main() method using class name.
there fore the main() method must be declared with public & static.....
Is This Answer Correct ? | 2 Yes | 0 No |
How do you define a method?
public class AboutStrings{ public static void main(String args[]){ String s1="hello"; String s2="hel"; String s3="lo"; String s4=s2+s3; //to know the hash codes of s1,s4. System.out.println(s1.hashCode()); System.out.println(s4.hashCode()); // these two s1 and s4 are having same hashcodes. if(s1==s4){ System.out.println("s1 and s4 are same."); }else System.out.println("s1 and s4 are not same."); } } Somebody told me that, == operator compares references of the objects. In the above example even though s1 and s4 are refering to same object(having same hash codes), it is printing s1 and s4 are not same. Can anybody explain in detail why it is behaving like this? Thanks in Advance RavuriVinod
Can you access the private method from outside the class?
Why wait and notify methods are declared in object class?
Can we create an object if a class doesn't have any constructor ( not even the default provided by constructor ) ?
What is an anonymous class in java?
Differentiate between postfix and prefix operators in java.
What is size () in java?
Can each java object keep track of all the threads that want to exclusively access it?
What is audio clip interface? Name few methods of it ?
Can array grow dynamically in java?
Is treeset sorted in java?