Logo

Java Questions Set 211:

Quiz Mode

Which access specifier must be used for the main() method?

1
2
3
4

Solution:

Which functions are called to display the output of an applet?

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

   int a=~3^4;

   int b=~4;

   System.out.println(~b&a);

}

}

1
2
3
4

Solution:

What will be the output of the following Java program?

class Output

{

public static void main(String[] args)

{

StringBuffer c = new StringBuffer("Hello");

c.delete(0, 2);

System.out.println(c);

}

}

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

   int a=7;

   int b=15;

   if(false==0)

   {

       System.out.println(~a);

   }

   else

   {

       System.out.println(b);    

   }

}

}

1
2
3
4

Solution:

What is the output of the following Java code?

class Abekus {

public static void main(String[] args)

{

int arr[] = new int[6];

System.out.println(arr);

System.out.println(arr[0]);

}

}

1
2
3
4

Solution:

Predict the output of the following Java code.

class Abekus {
public static void main(String args[])
{
String str = "Java on Abekus";
String str1 = "Abekus";
if (str.regionMatches(8, str1, 0, 5))
System.out.println("is Equal");
}
}

1
2
3
4

Solution:

What will be the output of the following Java code?

class Output {

public static void main(String args[]) {

byte a[] = { 65, 66, 67, 68, 69, 70 };

byte b[] = { 71, 72, 73, 74, 75, 76 };

System.arraycopy(a, 1, b, 3, 0);

System.out.print(new String(a) + " " + new String(b));

}

}

1
2
3
4

Solution:

Predict the output of the following Java code:

public class Abekus extends Thread {

public static void main(String[] args) {

String a = "Abekus";

String b = new String(a);

int i = 0;

i = (a == b) ? 4 : 10;

if (i == 4)

{

System.out.println("Amrit");

}

else if (i == 10)

{

System.out.println("Milind");

}

else

{

System.out.println("Anand");

}

}

}

1
2
3
4

Solution:

What will be the output of the following Java program?


    class exception_handling 

    {

            static void throwexception() throws ArithmeticException 

            {        

                System.out.print("1");

                throw new ArithmeticException ("Exception");

            }

            public static void main(String args[]) 

            {

            try 

            {

                throwexception();

            }

            catch (ArithmeticException e) 

            {

                    System.out.println("B");

            }

        }

    }


1
2
3
4

Solution: