Logo

Java Questions Set 238:

Quiz Mode

What does an annotation type definition look similar to?

1
2
3
4

Solution:

Predict the output of the following Java code.

1
2
3
4

Solution:

What will be the output of the following Java program that demonstrates object serialization and deserialization?

1
2
3
4

Solution:

What will be the output of the following Java code?

class Output

{

public static void main(String args[])

{

String c = "Hello i love java";

boolean var;

var = c.startsWith("hello");

System.out.println(var);

}

}

1
2
3
4

Solution:

What will be the output of the following Java code?

import java.util.Scanner;

public class Main

{

    public static void main(String args[])

    {

String s1 = "Abekus";

String s2 = "Abekus";

System.out.println(s1 == s2);

    }

}

1
2
3
4

Solution:

What will be the output of the following Java program?


class exception_handling 

{

public static void main(String args[]) 

{

try 

{

int a, b;

               b = 0;

               a = 5 / b;

System.out.print("A");

}

catch(ArithmeticException e) 

{

System.out.print("B"); 

}

}

}

1
2
3
4

Solution:

Given the following code:

class X implements Runnable
{
   public static void main(String args[])
   {
       /* Missing code? */
   }
   public void run() {}
}

Which of the following lines of code is suitable to start a thread?

1
2
3
4

Solution:

Predict the output of the following Java code.

class Abekus

{

public static void main(String[] args)

{

try

{

System.out.println(5/0);

}

catch(ArithmeticException e)

{

System.out.println(e.getMessage());

}

}

}

1
2
3
4

Solution:

class exception_handling

    {

        public static void main(String args[])

        {

            try 

            {

                int i = args.length;

                int j = 10 / i;

                System.out.print(i);

                try 

                {

                     if (i == 1)

                         i = i / i - i;

                     if (i == 2)

                     {

                         int c = {1};

                         c[8] = 9;

                     }

                }

                catch (ArrayIndexOutOfBoundException e)

                {

                    System.out.println("Abekus");

                }

                catch (ArithmeticException e)

                {

                    System.out.println("Slack");

                }

            }

        }

    }

1
2
3
4
5

Solution: