Logo

Java Questions Set 160:

Quiz Mode

Which Java class is related to all the exceptions that can be caught using a catch block?

1
2
3
4

Solution:

If a member of a class does not implement serialization, which exception would be thrown?

1
2
3
4

Solution:

Predict the output of the following Java code.

public class Abekus {

public static void main(String[] args)

{

int $_ = 56;

System.out.println($_);

}

}

1
2
3
4

Solution:

Which one of these lists contains only Java programming language keywords?

1
2
3
4

Solution:

What will be the output of the following Java program?


public class Test
{
private static float[] f = new float[2];
public static void main(String[] args)
{
System.out.println("f[0] = " + f[0]);
}
}

1
2
3
4

Solution:

what should be the output of this code block ?

 public class abekus {

  public static void main(String[] args) {

   int a = -5;

   a += 5;

   switch (a) {

   case 5:

    System.out.print("5");

    break;

   case 10:

    System.out.print("10");

   default:

    System.out.print("0-2");

   }

  }

 }

1
2
3
4

Solution:

Predict the output of the following Java code:

import java.util.Scanner;

public class MyClass {

public static void main(String args[]) {

StringBuffer str = new StringBuffer("corejava");

str.delete(2,4);

System.out.println(" " + str);

}

}

1
2
3
4

Solution:

 What is the output of this program?

class StringDemo 

    {

        public static void main(String args[])

        {

            char chars[] = {'A', 'B', 'C', 'D'};

            String str1 = new String(chars);

            String str2 = "ABCDE";

            int len1 = str2.length();

            int len2 = str1.length();

            System.out.println(len1 + " " + len2);

        }

   }

1
2
3
4

Solution:

What is the output of the following program?

class newthread implements Runnable 

    {

Thread t;

        newthread() 

        {

            t = new Thread(this,"My Thread");

            t.start();

}

public void run() 

        {

   System.out.println(t.getName());

}

    }

    class multithreaded_programing 

    {

        public static void main(String args[]) 

        {

            new newthread();        

        }

    }

1
2
3
4

Solution: