suppose string s1="rajnish";
string s2="bhaskar";
then what will be happend ?

Answer Posted / venkat

FIRST OF ALL THE JVM CREATED THE OBJECTS FOR STRING
CLASSESS IN TWO WAYS
1)STRING S1=NEW STRING("VENKI");
2)STRING S2="VENKI"
IN SECOND APPROACH WHEN THE JVM IS EN COUNTED THE ""
(DOUBLE QUOTATIONS) THEN IT UNDERSTOOD ,AND CREATED THE
OBJECT FOR THE S2 , AND THIS OBJECT IS PLACED IN THE STRING
POOL (SEPERATE MEMORY LOCATION IS MAINTAINED) . i.e in this
position we are not creating the object for the string class
explicitly ,the jvm internally created this object

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you execute a thread in java?

505


What are the different types of constructor?

526


What do you understand by copy constructor in java?

492


What is numeric function?

542


Which of the following is not an isolation level in the JDBC

1612






What is parse method?

541


What is casting in java programming?

585


What do you mean by byte code?

513


What is the difference between a factory and abstract factory pattern?

683


Difference between error and exception

5017


What is the purpose of declaring a variable as final?

486


Explain how can you debug the Java code?

590


What do you mean by mnemonics?

534


What is string builder in java?

556


2) Suppose there are 5 directories having lot of files (say txt files) in each directory. 2 things :- 2.1) You want to search for filenames which have a particular pattern. 2.2) Out of these filtered files you want to search for a particular keyword or a search string. How can you achieve this?

1835