WorksheetsJava Quiz (Basics)
Total questions: 10
Worksheet time: 5mins
Find the output of the following code.
int Integer = 24;
char String = ‘I’;
System.out.print(Integer);
System.out.print(String);
Compile error
Throws Exception
1
241
Find the output of the following program.
public class Solution
{
public static void main(String[] args)
{ short x = 10; x = x * 5; System.out.print(x); } }
50
10
compile error
Exception
Find the output of the following program.
public class Solution
{
public static void main(String[] args)
{ byte x = 127; x++; x++; System.out.print(x); } }
-127
127
129
2
Find the output of the following program.
public class Solution
{ public static void main(String[] args)
{ int[] x = {120, 200, 016};
for(int i = 0; i < x.length; i++)
{ System.out.print(x[i] + “ “);
} } }
120 200 016
120 200 14
120 200 16
None
When an array is passed to a method, what does the method receive?
The reference of the array
The copy of the array
Length of the array
Copy of first element
Find the value of A[1] after execution of the following program.
int[] A = {0,2,4,1,3}; for(int i = 0; i < A.length; i++){ A[i] = A[(A[i] + 3) % A.length]; }
0
1
2
3
Arrays in java are-
Object refrences
Objects
Primitive data type
None
Find the output of the following code.
int ++a = 100;
System.out.println(++a);
101
Compile error as ++a is not a valid identifier
100
None
Find the output of the following code.
if(1 + 1 + 1 + 1 + 1 == 5)
{
System.out.print(“TRUE”);
}
else
{ System.out.print(“FALSE”); }
TRUE
FALSE
Compile error
None
Find the output of the following code.
Public class Solution
{
Public static void main(String… argos)
{ Int x = 5; x * = (3 + 7); System.out.println(x);
}}
50
22
10
None
