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
Loading...
2. import myLibrary.*;
public class ShowSomeClass
{
// code for the class...
}
What is the name of the java file containing this program?
[A] . myLibrary.java
[B] ShowSomeClass.java
[C] ShowSomeClass
[D] ShowSomeClass.class
Loading...
3. Consider the following code snippet
String river = new String('Columbia”);
System.out.println(river.length());
What is printed?
[A] 6
[B] 7
[C] 8
[D] river
Loading...
4. : If s = "text", what is the value returned by s.length()?
[A] 4
[B] 5
[C] True
[D] False
Loading...
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
Loading...
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
Loading...
7. Given the following statement:
huey.setDouble(8.0*32.2+1.0);
What must be the data type of huey?
[A] Double Field
[B] Text Field
[C] Int field
[D] Double
Loading...
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
Loading...
9. Which of these method of String class is used to obtain character at specified index?
[A] char()
[B] Charat()
[C] charat()
[D] charAt()
Loading...
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()
Loading...
Are these questions helpful for you?

Comments: (Your feedback is valuable to us)