NEW
Font size
WorksheetsCODEBURST : JAVA EDITION
Total questions: 20
Worksheet time: 20mins
What is the output of the following code?
String str = null;
System.out.println(str + "abc");
What is the result of compiling and running this code?
int x = 5;
System.out.println(x++ + ++x);
What is the output of the following code?
public class Test
{ public static void main(String[] args)
{ int a = 3;
int b = 4;
int result = a++ * ++b;
System.out.println(result); } }
What is the output of the following code?
public class ArrayTest
{ public static void main(String[] args)
{ int[] arr = new int[5];
System.out.println(arr[2]); } }
What is the output of the following code?
public class ExceptionTest
{ public static void main(String[] args)
{ try
{ int x = 5 / 0; }
catch (ArithmeticException e)
{ System.out.print("A"); }
catch (Exception e)
{ System.out.print("B"); }
finally
{ System.out.print("C"); } } }
Output of this code?
import java.util.*;
public class HashSetTest
{
public static void main(String[] args)
{
Set set = new HashSet<>();
set.add("one");
set.add("two");
set.add("one");
System.out.println(set.size()); }
}
What is the output of the following code?
class Parent
{
static void display()
{
System.out.println("Parent"); }
}
class Child extends Parent
{
static void display()
{ System.out.println("Child"); }}
public class Test
{
public static void main(String[] args)
{
Parent obj = new Child();
obj.display(); } }
What is the output of the following code?
public class ShiftTest
{ public static void main(String[] args)
{
System.out.println(2 << 3); } }
What is the output of the following code?
public class LoopTest
{
public static void main(String[] args)
{
for (int i = 0; i < 3; i++)
{
System.out.print(i);
}
System.out.print(i);
} }
What is the output of the following code?
public class StringPool
{
public static void main(String[] args)
{ String s1 = new String("java");
String s2 = "java";
System.out.println(s1 == s2); } }
What is the output of the following code?
import java.util.*;
public class ListTest
{
public static void main(String[] args)
{
List list = Arrays.asList(1, 2, 3);
list.set(0, 10);
System.out.println(list); } }
What is the output of the following code?
public class XORTest
{ public static void main(String[] args)
{ int x = 5 ^ 3;
System.out.println(x); } }
