Skip to main content

Strings — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Strings — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

Which of the following is true about Java strings?

Question 2 of 40
★ FPSC ★ PPSC

What is the purpose of the trim() method of a String object in Java?

Question 3 of 40
★ FPSC ★ PPSC

Which of the following methods is used to replace all occurrences of a specified character in a string in Java?

Question 4 of 40
★ FPSC ★ PPSC

The output of the following fraction of code is public class Test{ public static void main(String args[]){ String s1 = new String("Hello"); String s2 = new String("Hellow"); System.out.println(s1 = s2); } }

Question 5 of 40
★ FPSC ★ PPSC

Determine output: public class Test{ public static void main(String args[]){ String s1 = "SITHA"; String s2 = "RAMA"; System.out.println(s1.charAt(0) > s2.charAt(0)); } }

Question 6 of 40
★ FPSC ★ PPSC

What will be the output? String str1 = "abcde"; System.out.println(str1.substring(1, 3));

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following program? public class Test{ public static void main(String args[]){ String str1 = "one"; String str2 = "two"; System.out.println(str1.concat(str2)); } }

Question 8 of 40
★ FPSC ★ PPSC

String str1 = "Kolkata".replace('k', 'a'); In the above statement, the effect on string Kolkata is

Question 9 of 40
★ FPSC ★ PPSC

How many objects will be created? String a = new String("Examveda"); String b = new String("Examveda"); String c = "Examveda"; String d = "Examveda";

Question 10 of 40
★ FPSC ★ PPSC

How many Constructor String class have?

Question 11 of 40
★ FPSC ★ PPSC

What will be output? String S1 = "S1 ="+ "123"+"456"; String S2 = "S2 ="+(123+456);

Question 12 of 40
★ FPSC ★ PPSC

In Java, which class is used to represent a sequence of characters as a string?

Question 13 of 40
★ FPSC ★ PPSC

What is the correct way to create a new empty String object in Java?

Question 14 of 40
★ FPSC ★ PPSC

In Java, which operator is used to concatenate two strings?

Question 15 of 40
★ FPSC ★ PPSC

Which of the following methods is used to compare two strings for equality in Java?

Question 16 of 40
★ FPSC ★ PPSC

What does the length() method of a String object in Java return?

Question 17 of 40
★ FPSC ★ PPSC

How do you convert a string to lowercase in Java?

Question 18 of 40
★ FPSC ★ PPSC

What is the purpose of the charAt() method of a String object in Java?

Question 19 of 40
★ FPSC ★ PPSC

Which method is used to find the index of the first occurrence of a specified character in a string in Java?

Question 20 of 40
★ FPSC ★ PPSC

In Java, what is the result of the expression "Hello".substring(1, 4)?

Question 21 of 40
★ FPSC ★ PPSC

What is the correct way to check if a string starts with a specific prefix in Java?

Question 22 of 40
★ FPSC ★ PPSC

Which method is used to split a string into an array of substrings based on a specified delimiter in Java?

Question 23 of 40
★ FPSC ★ PPSC

In Java, what is the purpose of the endsWith() method of a String object?

Question 24 of 40
★ FPSC ★ PPSC

What method is used to convert an integer to a string in Java?

Question 25 of 40
★ FPSC ★ PPSC

Which of the following is the correct way to compare two strings in a case-insensitive manner in Java?

Question 26 of 40
★ FPSC ★ PPSC

In Java, what does the concat() method of a String object do?

Question 27 of 40
★ FPSC ★ PPSC

How do you find the last index of a specified character in a string in Java?

Question 28 of 40
★ FPSC ★ PPSC

What is the result of the expression "Java".replace("a", "o") in Java?

Question 29 of 40
★ FPSC ★ PPSC

Which of the following is true about string concatenation in Java?

Question 30 of 40
★ FPSC ★ PPSC

How do you find the index of the last occurrence of a substring in a string in Java?

Question 31 of 40
★ FPSC ★ PPSC

What is the purpose of the toLowerCase() method of a String object in Java?

Question 32 of 40
★ FPSC ★ PPSC

Which method is used to extract a substring from a string in Java?

Question 33 of 40
★ FPSC ★ PPSC

In Java, what is the purpose of the isEmpty() method of a String object?

Question 34 of 40
★ FPSC ★ PPSC

How do you check if a string contains a specific character in Java?

Question 35 of 40
★ FPSC ★ PPSC

What is the purpose of the substring() method of a String object in Java?

Question 36 of 40
★ FPSC ★ PPSC

How do you find the first index of a specified character in a string in Java?

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following program code? class LogicalCompare{ public static void main(String args[]){ String str1 = new String("OKAY"); String str2 = new String(str1); System.out.println(str1 == str2); } }

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following program? public class Test{ public static void main(String args[]){ String s1 = "java"; String s2 = "java"; System.out.println(s1.equals(s2)); System.out.println(s1 == s2); } }

Question 39 of 40
★ FPSC ★ PPSC

What could be output of the following fragment of code? public class Test{ public static void main(String args[]){ String x = "hellow"; int y = 9; System.out.println(x += y); } }

Question 40 of 40
★ FPSC ★ PPSC

toString() method is defined in

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →