ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
I have a String s = java; What is the output when I say
s.replaceAll('j', 'k'); Also what is the value of s after
replacing?
 Question Submitted By :: Maria
I also faced this Question!!     Rank Answer Posted By  
 
  Re: I have a String s = java; What is the output when I say s.replaceAll('j', 'k'); Also what is the value of s after replacing?
Answer
# 1
String s="java";
s.repalce('j','k');

System.out.println(s);

output is: java
because String is immutable.we cannt change of string 
content.suppose u have to write 
 s=s.repalce('j','k');

output is :kava
 
Is This Answer Correct ?    8 Yes 2 No
Vikneswarank
[Jadian]
 
  Re: I have a String s = java; What is the output when I say s.replaceAll('j', 'k'); Also what is the value of s after replacing?
Answer
# 2
No, the strings are immutable; the value of s will be the 
same but new object kava will get crated which wil have no 
refrence. s will refer to the same object which is not 
changed.
s=s.replace("",""); should have worked...otherways
 
Is This Answer Correct ?    2 Yes 1 No
Puneet
 
 
 
  Re: I have a String s = java; What is the output when I say s.replaceAll('j', 'k'); Also what is the value of s after replacing?
Answer
# 3
replaceAll take two strings as parameter
but in the given question characters are given as parameter
hence it is an error
 
Is This Answer Correct ?    2 Yes 3 No
Prabhavith
 
  Re: I have a String s = java; What is the output when I say s.replaceAll('j', 'k'); Also what is the value of s after replacing?
Answer
# 4
when u say s.replaceAll('j','k') their will be no output but
internally the string s will be stored as kava. so when u
ask for the output the output will be kava
 
Is This Answer Correct ?    2 Yes 2 No
Nikhil Hegde
 
  Re: I have a String s = java; What is the output when I say s.replaceAll('j', 'k'); Also what is the value of s after replacing?
Answer
# 5
public class Test {

	public static void main(String args[])
	{
		
		String s="java";
		System.out.println("Before>>>>>>>"+s);
		s=s.replaceAll("j", "k");
		System.out.println("After>>>>>>>"+s);
		
		
	}
}
----------------------Output---------
Before>>>>>>>java
After>>>>>>>kava
 
Is This Answer Correct ?    3 Yes 0 No
Pradeep Rout
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Q) I have a ArrayList object, in that object i have added 5 integer values, 5 float values, 5 string values. Now question is how can delete particular type of data ( i.e all int values or all float values or string values) in that list object at a time? Aricent2
what is difference between String buffer and String builder? Benchmark2
What is the immediate superclass of the Dialog class?  1
Consider that class classA, abstract class classB, and final classC have been defined.Which one of the following is correct? 1. classA extends classC implements classB 2. class A extends classB, classC 3. classA extends classB 4. classB implements classC  1
What are init(), start() methods and whey they are called?  2
What is means by DLL file means ? What is the use of DLL file? What are the contents of DLL file?  2
what is meant by UP& DOWN casting in java?  4
How do you load an HTML page from an Applet ?  2
We have two methods to create methods the threads. 1. Implementing runnable interface 2. Extending to thread class and overriding run method. Among these two which one is better and why? Please explain me in detail.  2
class A{ m2(){ } } class B extends A{ m2(){ } } class c extends B{ m2(){ } } class my_class extends c{ m2(){ } pulic static void main(){ ...My_class a = new my_class(); super.super.super.m2(); is this is leagal if not find what is the legal procedure in order to call A's version of m2(); } Logica-CMG8
What are the Object and Class that classes used for?  3
What is Vector?Can you elaborate how Vector is Thread safe?  3
can we create a instance for intwerface?  3
Difference between local and global transaction ? iFlex1
What is the default initialized value of a boolean type variable?  3
Java support what type of parameter passing ? Wipro6
Explain in detail about encapsulation with an example?  3
String is a immutable objects . it means that string does not change........... But it will be chang......... { String s="kapil"; String s1="raj"; String s=s1; then print(.......) The String has been changed .. how it is possible and why its called immutable objects  3
why Runnable interface is preferable than extending the Thread class? Wipro5
what is bytecode ?explain in detail and watz the difference between bytecode and machine code? Lucent3
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com