Logo

Java Questions Set 227:

Quiz Mode

Which of these classes is super class of Exception class?

1
2
3
4

Solution:

Which class is the superclass of the String and StringBuffer classes?

1
2
3
4

Solution:

Which of these keywords is used to enclose the block of code that needs to be checked for exceptions?

1
2
3
4

Solution:

public class operators {

public static void main(String[] args)

{

int a = 20, b = 10, c = 0;

a = b++ + c;

System.out.println(b);

}

}

1
2
3
4

Solution:

Predict the output of the following Java code:

class Abekus {
static int i = 1;
public static void main(String[] args)
{
for (int i = 1; i < 12; i++) {
i = i + 2;
System.out.print(i + " ");
}
}
}

1
2
3
4

Solution:

both statement/code are same or not


Statement 1

class x{

  public void m1(){

         if(true){

                 throw new RTE("Abekus");

              }

    }

}

--------------------------------------------

Statement 2

class x{

public void m2() throws RTE {

      if(true){

           throw new RTE("Abekus")

           }  

     }

}

1
2

Solution:

Predict the output of the following Java code:

class Abekus {

public static void swap(Integer a, Integer b) {

Integer temp = a;

a = b;

b = temp;

}

public static void main(String[] args) {

Integer a = new Integer(55);

Integer b = new Integer(68);

swap(a, b);

System.out.println("a = " + a + ", b = " + b); }

}

1
2
3
4

Solution:

Predict the output of the following Java code:

class Abekus {
public static void main(String args[])
{
String str = "Java Programming";
String str1 = "Java";
String str2 = str.substring(7);
System.out.println(str2);
System.out.println(str.substring(7, 11));
}
}

1
2
3
4

Solution:

Predict the output of the following Java code.

import java.util.*;

public class Abekus {

public static void main(String[] args) {

List<String> l = new ArrayList<String>();

l.add("d");

l.add("f");

l.add("a");

l.add("g");

l.add("b");

Collections.rotate(l, 2);

System.out.println(l);

}

}

1
2
3
4

Solution: