|
INTERVIEW QUESTIONS
J2EE
JAVA
DETAILS
Question: In Java, You can create a String object as: String str = "abc"; & String str = new String("abc");Why
Answer: string x="abc"
string y ="abc" i dont think that here they refer to same object.I have refer the complete reference..automatically when u asign stringz like this ..different objects will b created
|
|
|
Category |
Java Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 7072 users |
Added on |
7/15/2011 |
Views |
68493 |
Rate it! |
|
|
Question:
In Java, You can create a String object as: String str = "abc"; & String str = new String("abc");Why
Answer:
string x="abc"
string y ="abc" i dont think that here they refer to same object.I have refer the complete reference..automatically when u asign stringz like this ..different objects will b created Source: CoolInterview.com
Hi... In java String s1="abc"; & String s2= new String("abc"); these are two ways to create string objects. String s1="abc" in this case one reference (s1) and one object (abc)will be created.Here "abc" object will be created in separate "Stringpool" ,it is a part of the main memory.This is a recommended way to create string objects in java. String s2=new String("abc"); in this case one reference(s2) and two object will be created . One is in "String pool" and another one is in "heap". Source: CoolInterview.com
Answered by: DEVARATHNAM C, KOTAGUDIBANDA(PO),KALAKADA(MD),CHIT | Date:
| Contact DEVARATHNAM C, KOTAGUDIBANDA(PO),KALAKADA(MD),CHIT
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How to make application thread-safe ?
|
View Answer
|
|
What is it object serialization ?
|
View Answer
|
|
What do you know about networking support in Java ?
|
View Answer
|
|
What you know about Corba implementation in Java ?
|
View Answer
|
|
What is Java Beans ?
|
View Answer
|
|
Compare SWING components to standard AWT.
|
View Answer
|
|
What is layout manager ? How does it work ?
|
View Answer
|
|
What are the advantages of OOPL?
|
View Answer
|
|
How many methods do u implement if implement the Serializable Interface?
|
View Answer
|
|
How do I instantiate a bean whose constructor accepts parameters using the useBean tag?
|
View Answer
|
|
Searching a String
|
View Answer
|
|
Connecting to a Database and Strings Handling
|
View Answer
|
|
What is the difference between Serializalble and Externalizable interface?
|
View Answer
|
|
What is the serialization?
|
View Answer
|
|
What are synchronized methods and synchronized statements?
|
View Answer
|
|
What is synchronization and why is it important?
|
View Answer
|
|
What is the purpose of finalization?
|
View Answer
|
|
What classes of exceptions may be caught by a catch clause?
|
View Answer
|
|
What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class
|
View Answer
|
|
What happens when a thread cannot acquire a lock on an object?
|
View Answer
|