No student devices needed. Know more
23 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"
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 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
int[] myArray = {11, 22, 33, 44, 55};
which code is correct to print length of above int-array?
System.out.println(int[].myArray.length());
System.out.println(myArray.length);
System.out.println(myArray.length());
System.out.println(int[].myArray.size());
String[] friends = {"John", "Mike", "Samantha", "Monica"};
which code is correct to print "Samantha" using array functionality?
System.out.println(friends[2]);
System.out.println(friends[3]);
System.out.println(friends["Samantha"]);
System.out.println(friends{2});
String[] friends = {"John", "Mike", "Samantha", "Monica"};
which code is correct to print "Samantha" using array functionality?
System.out.println(friends[2]);
System.out.println(friends[3]);
System.out.println(friends["Samantha"]);
System.out.println(friends{2});
Select correct code to create an array of "double" datatype of length 5.
double arr = double[5];
double{} arr = new double{5};
double[5] arr = new double[];
double[] arr = new double[5];
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
Java code to create a non-element array of student marks with the size of 20.
double mark;
double [20] mark = new double;
double [ ] mark = new mark [20];
double [ ] mark = new double [20];
Java code to create a non-element array of student name with size 15.
String [ ] name = new String;
String [ ] name = new String [15];
name = new String [15];
String [15] name = new String [ ];
Java code to create an array of student id with element 115331, 450055, 555641, 875560 and 987555.
int [ ] id = new {115331, 450055, 555641, 875560, 987555};
int [5] id = {115331, 450055, 555641, 875560, 987555};
int [ ] id = {115331, 450055, 555641, 875560, 987555};
int [ ] id = new int [5];
Java code to display the size of an array name studentname[ ].
System.out.println("The size is " + studentname[ index ]);
System.out.println("The size is " + studentname.length);
System.out.println("The size is " + length.length);
System.out.println("The size is " + studentname);
Java code to read elements into array studentname[ ].
Based on the code segment below:- identify the name of the array.
for(int j=0; j<balance.length; j++)
{
System.out.print("Enter amount: ");
.......
}
No answer.
temp[ ]
balance
balance [ i ]
Based on the code segment below:- identify the name of the array.
for(int j=0; j<balance.length; j++)
{
System.out.print("Enter amount: ");
.......
}
No answer.
temp[ ]
balance
balance [ i ]
Explore all questions with a free account