Strings
- What is the output of this program?
public class Result
{
public static void main(String[]args)
{
String[] array = { "for", "tea", "too" };
String num= (array.length > 2) ? array[2]: null;
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
The value at the 0th position will be assigned to the variable num.
- What is the output of this program?
public class stringClass_Example
{
public static void main(String args[])
{
String str = "Interview";
String str1 = "Mania";
String str2 = "Interview";
System.out.println(str.equals(str1) + " " + str.equals(str2));
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
equals() is method of class String, it is used to check equality of two String objects, if they are equal, true is retuned else false.
output: false true
- Which of these keywords is used to refer to member of base class from a subclass?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Whenever a subclass needs to refer to its immediate superclass, it can do so by use of the keyword super.
- Which of the following statements are incorrect?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Strings in Java are immutable that is they can not be modified.
- Which of these method of String class can be used to test to strings for equality?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
equals()