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
 
Keywords in Exceptions?  1
what is ejb? what is the importance of ejb? Photon1
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
how many design pattern r there? and wht design pattern u use and why ? HP5
How many bits are used to represent unicodde,ASCII,UTF-16 and UTF-8 characters?  2
When will we use class loader?  1
write a simple program inheritance? Polaris2
different types of threads? TCS7
Name the types of 'priority'?  2
why java not supproting multiple inheritance?  5
What is Transient and volatile iFlex9
Can try statements be nested? Wipro2
Difference between Applet & Application?  5
what is the use of datasource in core java? Satyam2
What are command line arguments?  2
How are this and super used?  5
What is meant by constructor?  4
printstream class method println() is calling using System class and its static object out .how it is explain any one in detail with example ? TCS1
what is auto boxing UHG1
How does Vector implement synchronization? Ness-Technologies2
 
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