String Inbuilt Methods
String Inbuilt Methods
B) GREAT joy
C) GREAT job
D) GREAT
job
1 // Predict the output
2
3 public class Main{
4 public static void main(String args[])
5 {
6 String str1 = "Great things never come from comfort zones";
7 if (str1.contains("Comfort"))
8 {
9 System.out.println("mountain");
10 }
11 else
12 {
13 System.out.println("peak");
14 }
15 }
16 }
17
18
19
20
21
22
Question 2
A) mountain
B) peak
C) Error
B) false
C) Error
B) false
C) Error
B) false true
C) true true
D) false false
1 // Predict the output
2
3 public class Main{
4 public static void main(String[] args) {
5 String s1 = "Rare";
6 StringBuffer sb1 = new StringBuffer("Rare");
7 String s2 = sb1.toString();
8 System.out.println(s1.equals(s2));
9 }
10 }
11
12
13
14
15
16
17
18
19
20
21
22
Question 6
A) true
B) false
C) Error
B) WelcomZ to programming..
C) WelcomZ
D) Error
1 // Predict the output
2
3 public class output{
4 public static void main(String args[])
5 {
6 StringBuffer s1 = new StringBuffer("Microsoft");
7 s1.insert(9 , " Employee");
8 System.out.println(s1);
9 s1.delete(0, 10);
10 System.out.println(s1);
11 }
12 }
13
14
15
16
17
18
19
20
21
22
Question 9
A) Microsoft Employee
Employee
B) Microsoft Employee
Employee
C) MicrosEmployee ft
Employee
D) Error
1 // Predict the output
2
3 public class Main
4 {
5 public static void main(String[] args)
6 {
7 StringBuilder str = new StringBuilder("Keep Going");
8 String str2 = str.toString();
9 StringBuilder s = str2.deleteCharAt(8);
10 System.out.println(s);
11 }
12 }
13
14
15
16
17
18
19
20
21
22
Question 10
A) Keep Goig
B) Keep Goin
C) Keep Gong
D) Error
THANK YOU