0% found this document useful (0 votes)
23 views13 pages

String Manipulation Programs

The document provides a list of 67 problems and exercises related to strings and string manipulation in Java. The problems cover topics like reversing strings, checking for palindromes, counting characters, splitting strings, comparing strings, and more.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views13 pages

String Manipulation Programs

The document provides a list of 67 problems and exercises related to strings and string manipulation in Java. The problems cover topics like reversing strings, checking for palindromes, counting characters, splitting strings, comparing strings, and more.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

STRINGS PROGRAMS

[Link] a String?

[Link] even words in a particular Sentence.

[Link] 5 mistakes of the following code.

package [Link]-interviews;

public class String programs {


static void main (String[10] args)
{
String s="abc";
[Link](s);
}
}

[Link] a program to check given String is pallindrome or not not by using reverse().

[Link] a program to check and print how many vowels in it.

[Link] a word in a String without using inbuilt function.

[Link] word in a String.

1
STRINGS PROGRAMS
[Link] a program to count number of words in a String

[Link] a string without using inbuilt functions.

[Link] a program to print alphabets in a given String.

[Link] a program to print duplicate characters in a given String.

[Link] a program to check whether the given two words are anagram or not.
silent,listen - anagram
listen,enlists -not an anagram.

[Link] the numbers from the string.

[Link] the longest word in the Sentence.


input:spacy's named entirely recognition has been trained On the on
output:recognition.

[Link] a program given number is convert to words


Ex 420 fourtwozero

[Link] a program to reverse a string.

[Link] a program to check whether the string is pallindrome or not.

2
STRINGS PROGRAMS

[Link] the string without using the string function.

[Link] Output{
public static void main(String[] args)
{
area obj = new area();
[Link](5,6);
[Link]([Link]+" "+[Link]);
}
}
a)00 b)56 c)65 d)56

[Link] of the following are incorrect form of StringBuffer class Constructor?


a)StringBuffer()
b)StringBuffer(int size)
c)StringBuffer(String str)
d)StringBuffer(int size,String str)

[Link] method is used in thread class to starts the execution of


thread jvm calls the run() on the thread?
a)public void start()
b)public void stop()
c)public void run()

3
STRINGS PROGRAMS
d)public void suspend()

[Link] DriverManager class which method is used to establish the connection


with the specified in?
a)public static void registerDriver(Driver driver)
b)public static void deregisterDriver(Driver driver)
c)public static Connection getConnection(String )
d)public static Connection getConnection(String ,StringuserName,String password)
[Link] will be the o/p?
public class Test{
public static void main (String[] args){
String x="abc";
String y="abc";
[Link](y);
[Link](x);
}
}
a)null
b)abc
c)abcabc

[Link] all valid methods of String class?


a) trim()
b)intern()

4
STRINGS PROGRAMS
c)toLower()
d)split()

[Link] implementation follows which of the below design pattern?


a)Flyweight Design Pattern
b)None of these
c)Singleton Pattern
d)Factory Pattern

[Link] will be the o/p?


String s1="abs";
String s2= new String("abc");
[Link](s1==s2);
[Link](s1==[Link]());
a)false false
b)true false
c)true true
d)false true

[Link] will be the o/p?


String s="Java String Quiz";
[Link]([Link](5,3));
a)Runtime Exception StringIndexOutOfBoundsException
b)Runtime Exception IndexOutOfBoundsException

5
STRINGS PROGRAMS
c)Compile time errr
prints"str"

[Link] of the following statements are true for StringBuffer and StringBuilder?
a)StringBuilder is not thread-safe
b)StringBuffer is thread safe because its methods are synchronized
c)StringBuffer and StringBuilder are immutable
d)StringBuilder was introduced in java 1.4
class String_class
{
public static void main(String[] args)
{
String obj ="Hello";
String obj1="World";
String obj2=obj;
obj2="World";
[Link](obj+" "+obj2);
}
}

28.W.A.P to print number of characters ina vowels and string

29.W.A.P to print number of vowels in a given string.

6
STRINGS PROGRAMS
[Link] a program to print number of words in string.

31.W.A.P for duplicate String

32.W.A.P for vowels count in a given String.

[Link] and string buffer.


W.A.P to print frequency of each character in a given string when count is a primary
number.

[Link] :aaaaBBBcdddd
Output:B-3,c-1

[Link] : a3b2c4
Output:aaabbcccc

[Link]:ak2b3r
output:akkbbbr

[Link]:aaaBBcd
output:a-3,B-2,c-1,d-1

[Link]:HelloWorld
Output:Helowrd

7
STRINGS PROGRAMS

[Link]:abcde
Output:badce

[Link] the vowels

[Link] of words in the strings.

[Link] class Test


{
void display(Test t){
[Link]("Test");
}
void display(String str)
{
[Link]("String");
}
public static void main(String[] args)
{
new Test().display(null);
}
}

[Link] class Metti{

8
STRINGS PROGRAMS
public static void main(String[] args)
{
String s="This is a line";
String[] tokens =[Link](" ");
[Link]([Link]);
}
}

[Link] static void main(String[] args)


{
String s1 = 'abc';
String s2 = 'ghi';
String s3 = s2;
s2='xyz';
[Link](s1+s2+s3);
}

[Link] static void main(String[] args)


{
Sample s1 = pinc();
[Link](pinc);
if(instance pinc)
{
[Link](pinc);

9
STRINGS PROGRAMS
}
else
{
[Link]("Oak");
}
}

[Link] static void main(String[] args)


{
String s1 = "ABCD";
String c=[Link]();
b=[Link]('a','d');
b=[Link]('b','c','d');
[Link](c);
}

[Link] void main(String[] args)


{
str1 = "abc";
str2 = "def";
[Link](s1+s2);
str2 = "ghi";
}

10
STRINGS PROGRAMS
[Link] i = (int)[Link]();

[Link] a string replace all the digits in the String with empty space.
eg-Fr33Zer
ans:FrZer

[Link] 2 numbers,calculate the hcf of the numbers,Eg -26,38.(26-2*13,38-2*19).Ans-


2

[Link] an array of numbers,find out the largest and smallest number and swap there
places.

[Link] 2 strings,merge the string,replacing any duplicate characters in [Link]:"hello"


and "World" Ans-"Helwrd"

[Link] a program for two Strings rotating manually?

[Link] a program where the same character is find in the String.

[Link] a program to find number of numerical digits ina string.

[Link] to get the matching characters in a string?

[Link] a program on
input :a,b,c,d,....,z

11
STRINGS PROGRAMS
output :a=1
b=2
.
.
z=26

[Link] a program on
input :xyz*abc-Hello*abcd
output:zyx*cba-olleH*dcba

[Link] the given string in reverse order.

62.W.A.P to reverse the String word by word


I/p :[Link]
O/P :[Link]
[Link] a program to count number of digits in a given String.
Enter a String Sam1sun2dar3
no of digits =3 those are 123

[Link] a program to print the count of the side by side Character same?
Example: Enter String:Ramaa
output :Ram2a

12
STRINGS PROGRAMS
[Link] a program to Convert Number in to Characters
Enter the Number=357546
three five seven five four six

[Link] on resversing a word in a string


Eg:Hello World
o/p:dlroW olleH

[Link] length encoding of a string.

[Link] a program to check whether the string is pallindrome or not?

13

You might also like