Java Programming Multiple Choice Questions - String

This section focuses on the "String" in Java programming. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements and other competitive examinations.

1. _________ are a sequence of characters.

A. Character
B. Strings
C. Integer
D. Classes

View Answer


2. In Java programming language, strings are treated as objects.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer


3. The String class is?

A. mutable
B. immutable
C. Both A and B
D. None of the above

View Answer


4. Methods used to obtain information about an object are known as?

A. string methods
B. class methods
C. object method
D. accessor methods

View Answer


5. Which methods to print output with formatted numbers?

A. printf()
B. format()
C. formatted()
D. Both A and B

View Answer


6. Which method returns the character at the specified index?

A. int compareTo(Object o)
B. int compareTo(String anotherString)
C. char charAt(int index)
D. int compareToIgnoreCase(String str)

View Answer


7. Which method returns a String that represents the character sequence in the array specified?

A. int compareToIgnoreCase(String str)
B. String concat(String str)
C. boolean contentEquals(StringBuffer sb)
D. static String copyValueOf(char[] data)

View Answer


8. Which of the following is true about boolean equals(Object anObject)?

A. Tests if this string ends with the specified suffix
B. Compares this string to the specified object
C. Compares this String to another String, ignoring case considerations
D. None of the above

View Answer


9. Which of these method of String class is used to obtain character at specified index?

A. char()
B. Charat()
C. charat()
D. charAt()

View Answer


10. Whenever a subclass needs to refer to its immediate superclass, it can do so by use of the keyword super.

A. Yes
B. No
C. Can be yes or no
D. Can not say

View Answer





Discussion



* You must be logged in to add comment.