Java Strings MCQs with answers Page - 1

You will find multiple-choice questions (MCQs) related to #Java Strings here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

A

Admin • 802.91K Points
Coach

Q. Which class is used to handle strings in Java?

  • (A) StringBuffer
  • (B) String
  • (C) StringBuilder
  • (D) Character

A

Admin • 802.91K Points
Coach

Q. Which of the following creates a string in Java?

  • (A) String s = 'hello';
  • (B) String s = "hello";
  • (C) String s = new char[5];
  • (D) String s = new String('hello');

A

Admin • 802.91K Points
Coach

Q. What is the output?
String s = "hello";
System.out.println(s.length());

  • (A) 4
  • (B) 5
  • (C) 6
  • (D) 0

A

Admin • 802.91K Points
Coach

Q. Which method is used to compare two strings for equality in Java?

  • (A) ==
  • (B) compare()
  • (C) equals()
  • (D) isEqual()

A

Admin • 802.91K Points
Coach

Q. What will this print?
String s = "Java";
System.out.println(s.charAt(2));

  • (A) J
  • (B) a
  • (C) v
  • (D) A

A

Admin • 802.91K Points
Coach

Q. Which method returns a substring in Java?

  • (A) substring()
  • (B) slice()
  • (C) cut()
  • (D) split()

A

Admin • 802.91K Points
Coach

Q. Strings in Java are:

  • (A) mutable
  • (B) final
  • (C) immutable
  • (D) primitive

A

Admin • 802.91K Points
Coach

Q. What will be the result?
"hello" == "hello"

  • (A) true
  • (B) false
  • (C) Compile-time error
  • (D) Runtime error

A

Admin • 802.91K Points
Coach

Q. Which method converts all characters to uppercase?

  • (A) toUpper()
  • (B) uppercase()
  • (C) convertUpper()
  • (D) toUpperCase()

A

Admin • 802.91K Points
Coach

Q. How do you concatenate two strings?

  • (A) str1.concat(str2)
  • (B) str1 + str2
  • (C) str1.append(str2)
  • (D) Both A and B
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More