String is an immutable object.
Then how can the following code be justified.
String s1 = ?ABC?;
String s1 = s1+?XYZ?;
s.o.p(s1);
The output is ABCXYZ, which is the value of s1 ?
Answer Posted / sivadasan
It will Give Compile time Error...
We can not declare again s1.
So the Compiler will give
s1 is already defined in main(java.lang.String[])
Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is externalizable?
Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.
What is the main difference between java platform and other platforms?
Why is a string immutable?
How many wrapper classes are there in java?
Can we declare array without size in java?
Can we clone singleton object?
What is the difference between throw and throws in java?
Are registers volatile?
What is the use of list in java?
Explain java code for recursive solution's base case?
Can we increase size of array?
Write down program for following scenario. Use java coding standard. You have array list with some words in it..we will call it as dictionary….and you have a arbitrary string containing some chars in it. You have to go through each word of dictionary and find out if that word can be constructed with the help of chars from arbitrary string given. If you find the word print it else print none.
Is it possible to use Semaphore/ Mutex in an Interrupt Handler?
What is flush () in java?