Logo

Java Questions Set 228:

Quiz Mode

Predict the output of the following Java code.

1
2
3
4
5

Solution:

Try and catch prevents automatic terminating of the program in cases when an exception occurs 

1
2

Solution:

Which of the following classes in Java is mutable?

1
2
3
4

Solution:

Predict the output of the following Java code.

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

   int a=64;

   int b=32;

   int c=~a|~b;

   System.out.print(c|a);

}

}

1
2
3
4

Solution:

Which of these Java classes can return more than one character to the input stream?

1
2
3
4

Solution:

What will be the output of the following Java code?

1
2
3
4

Solution:

 

What will be the output of the program?

class BitShift
{
   public static void main(String [] args)
   {
       int x = 0x80000000;
       System.out.print(x + " and  ");
       x = x >>> 31;
       System.out.println(x);
   }
}

1
2
3
4

Solution:

What will be the correct output?

public class Main {

 int x=9;

 public void add(int i)

 {

 System.out.println("integer value passed.\n");

 }

 public void add(float i)

 {

 System.out.println("float value passed.\n");

 }

 public static void main(String[] args) {

 Main m=new Main();

 m.add('a');

 }

}

1
2
3
4

Solution:

Predict the output of the following Java code:

class Abekus {
public static void main(String args[])
{
String str1 = "Hello";
char arr[] = { 'H', 'e', 'l', 'l', 'o', ' ', 'A',
'b', 'e', 'k', 'u', 's' };
String str2 = new String(arr);
System.out.println(str1);
System.out.println(str2);
}
}

1
2
3
4

Solution: