No student devices needed. Know more
20 questions
Is String a primitive data type?
Yes
No
Both
Which method to use to find length of a string?
length()
size()
long()
count()
Which data type gets returned from length() method in String class?
double
String
int
number
String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
What is the correct way to find the length of "txt" string?
int len = length(txt);
float len = txt.length();
int len = txt.length();
double len = length(txt);
Which is correct method to convert String into uppercase
changeUpperCase()
convertUpperCase()
toUpper()
toUpperCase()
String txt = "Hello World";
System.out.println(txt.toUpperCase());
Choose the correct output.
"HELLO WORLD"
HELLO WORLD
Hello world
Hello World
Choose correct purpose of indexOf() in String class.
returns the index (the position) of the last occurrence of a specified text in a string
returns the character of the first occurrence of a specified character in a string
returns the index (the position) of the first occurrence of a specified text in a string (excluding whitespace)
returns the index (the position) of the first occurrence of a specified text in a string (including whitespace)
String x = "10";
String y = "20";
String z = x + y;
System.out.println(z);
Guess the output.
1020
10 20
30
"10 20"
What will be the output of below code?
String statement = "Outfit of the day";
System.out.println(statement.Substring(3,6));
it of
tfit
fit
FIT
Choose most appropriate purpose of trim() method in String?
to remove white spaces
to get a substring of the string
to cut String at desired index
to remove extra white spaces from start and end of String
What is the return type of equalsIgnorecase() method?
int
String
char
boolean
What is the most appropriate way to check if two Strings are identical?
string1 == string2
string1.equals(string2)
string1.same(string2)
string1.equalsIgnorecase(string2)
(Multiple answer question)
Pick all NON-primitive datatypes from below :
String
int
primitive
Array
What is the correct relation between length and last-index of array?
last-index is always 1 more than the length
last-index is 1 less than the length (but not always)
last-index is always 1 less than the length
last-index is always equal to the length
String word = "A few good men";
What is word.indexOf(“f”)?
2
0
1
3
Explore all questions with a free account