gs gs128 Java String Handling - String Comparison in java - Quiz No.1
gs gs128 Java Quiz
This quiz belongs to book/course code gs gs128 Java of gs organization. We have 136 quizzes available related to the book/course Java. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Java String Handling. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: Which of these method of class String is used to compare two String objects for their equality?
equals()
Equals()
isequal()
Isequal()
Question 2: Which of these methods is used to compare a specific region inside a string with another specific region in another string?
regionMatch()
match()
RegionMatches()
regionMatches()
Question 3: Which of these methods of class String is used to check whether a given object starts with a particular string literal?
startsWith()
endsWith()
Starts()
ends()
Question 4: What is the value returned by function compareTo() if the invoking string is less than the string compared?
zero
value less than zero
value greater than zero
none of the mentioned
Question 5: Which of these data type value is returned by equals() method of String class?
char
int
boolean
all of the mentioned
Question 9: In the following Java code, which code fragment should be inserted at line 3 so that the output will be: “123abc 123abc”?
1. StringBuilder sb1 = new StringBuilder("123"); 2. String s1 = "123"; 3. // insert code here 4. System.out.println(sb1 + " " + s1);
sb1.append(“abc”); s1.append(“abc”);
sb1.append(“abc”); s1.concat(“abc”);
sb1.concat(“abc”); s1.append(“abc”);
sb1.append(“abc”); s1 = s1.concat(“abc”);