Java Programming - Java Strings Questions and Answers

Java Programming Questions and answers on String in the form of MCQ. Each Question have 4 options with one correct answer.
1. String is an________
[A] class
[B] Variable
[C] Array
[D] Data type
2. import myLibrary.*;
public class ShowSomeClass
// code for the class...
What is the name of the java file containing this program?
[A] .
[C] ShowSomeClass
[D] ShowSomeClass.class
3. Consider the following code snippet
String river = new String('Columbia”);
What is printed?
[A] 6
[B] 7
[C] 8
[D] river
4. : If s = "text", what is the value returned by s.length()?
[A] 4
[B] 5
[C] True
[D] False
5. What is the difference between a TextArea and a TextField?
[A] A TextArea can handle multiple lines of text
[B] A textarea can be used for output
[C] TextArea is not a class
[D] TextAreas are used for displaying graphics
6. Given the following code fragment:
int A[];
int i = 0;
A = new int A[4];
while (i < 4)
A[i] = 10;
i = i + 1;
What is the value of A[3]?
[A] 0
[B] 3
[C] 10
[D] unknown
7. Given the following statement:
What must be the data type of huey?
[A] Double Field
[B] Text Field
[C] Int field
[D] Double
8. : A compound statement is:
[A] A collection of one or more statements enclosed in braces
[B] A statement involving if and else
[C] A way of declaring variables
[D] a way of setting the value of a variable
9. Which of these method of String class is used to obtain character at specified index?
[A] char()
[B] Charat()
[C] charat()
[D] charAt()
10. Which of these method of String class can be used to test to strings for equality?
[A] isequal()
[B] isequals()
[C] equal()
[D] equals()
Are these questions helpful for you?

Comments: (Your feedback is valuable to us)