Java Strings MCQs with answers Page - 5

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 • 832.01K Points
Coach

Q. Which method is used to get a part of the string starting from a specific index?

  • (A) substring(int)
  • (B) slice(int)
  • (C) subString(int, int)
  • (D) cut(int)

A

Admin • 832.01K Points
Coach

Q. What will be the output of:
System.out.println("Java".substring(1, 3));

  • (A) av
  • (B) Ja
  • (C) va
  • (D) avJ

A

Admin • 832.01K Points
Coach

Q. Which of the following is NOT a valid string method?

  • (A) charAt()
  • (B) length()
  • (C) substring()
  • (D) characterAt()

A

Admin • 832.01K Points
Coach

Q. What is the result of:
"abc".equalsIgnoreCase("ABC")?

  • (A) true
  • (B) false
  • (C) ABC
  • (D) abc

A

Admin • 832.01K Points
Coach

Q. How to find the first occurrence of 'e' in the string "hello"?

  • (A) indexOf('e')
  • (B) find('e')
  • (C) charAt('e')
  • (D) get('e')

A

Admin • 832.01K Points
Coach

Q. Which method is used to check if a string matches a given regular expression?

  • (A) checkRegex()
  • (B) match()
  • (C) matches()
  • (D) regexMatch()

A

Admin • 832.01K Points
Coach

Q. How can you convert an integer to a string in Java?

  • (A) String.valueOf(int)
  • (B) Integer.toString(int)
  • (C) Both A and B
  • (D) toString(int)

A

Admin • 832.01K Points
Coach

Q. What will be the result of:
"hello".replace('l', 'x')?

  • (A) hexxo
  • (B) hexxlx
  • (C) helxo
  • (D) hexx

A

Admin • 832.01K Points
Coach

Q. What is the output?
System.out.println("Java".length());

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

A

Admin • 832.01K Points
Coach

Q. Which method can split a string using a regular expression?

  • (A) split()
  • (B) cut()
  • (C) tokenize()
  • (D) divide()
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