NEW
Font size
WorksheetsJava Quiz 3
Total questions: 15
Worksheet time: 11mins
ar, given the following declaration:int[] ar = {2, 4, 6, 8 }0, 1, 2, 31, 2, 3, 40, 2, 4, 6Is String a primitive data type?
Yes
No
Both
Find the output
class Test {
public static void main(String args[]) {
int arr[2];
System.out.println(arr[0]);
System.out.println(arr[1]);
}
}
Compile error
Exception
Garbage Value
Garbage Value
0
0
Output of following Java program?
class Test{
public static void main (String[] args) {
int arr1[] = {1, 2, 3};
int arr2[] = {1, 2, 3};
if (arr1 == arr2)
System.out.println("Same");
else
System.out.println("Not same");
}}
Same
Not same
Error
What is the length of the following array: byte[] data = { 12, 34, 9, 0, -62, 88 };
1
5
6
12
class Demo1
{
public static void main(String args[])
{
int i[] = new int[0];
System.out.println(i[0]);
}
}
0
Garbage Value
Exception
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 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 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)
