What is the base class of all classes?
java.lang.Object
What do you think is the logic behind having a single base class for all classes?
What is the importance of == and equals() method with respect to String object?
== is used to check whether the references are of the same object.
.equals() is used to check whether the contents of the objects are the same. But with respect to strings, object refernce with same content will refer to the same object. String str1="Hello"; String str2="Hello"; (str1==str2) and str1.equals(str2) both will be true. If you take the same example with Stringbuffer, the results would be different. Stringbuffer str1="Hello"; Stringbuffer str2="Hello"; str1.equals(str2) will be true. str1==str2 will be false. Is String a Wrapper Class or not?
No. String is not a Wrapper class.
How will you find length of a String object?
Using length() method of String class.
How many objects are in the memory after the exection of following code segment?
|
Friday, January 25, 2013
java.lang Package Interview Question And Answer
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment