Logo

Java Questions Set 16:

Quiz Mode

Treemap is a 

1
2
3
4

Solution:

Tree set and the map must be the comparable type

1
2

Solution:

Range of 'byte' datatype is :

1
2
3
4

Solution:

Which method is called first each time a servlet is called?

1
2
3
4

Solution:

In Java, after executing the following code segment, what are the values of a, b, and c?

int a, b=12, c=20;

a = b++ + c++;

1
2
3
4

Solution:

 

Statement 1-StringBuilder introduced in java 1.5
Statement 2-StringBuilder introduced in java 1.4
Statement 3-StringBuilder introduced in java 1.6
Statement 4-StringBuilder introduced in java 1.7

1
2
3
4

Solution:

Predict the output of the following Java program.

class Test {

public static void main(String[] args) {

for(int i = 0; 0; i++)

{

System.out.println("Hello");

break;

}

}

}

1
2
3
4

Solution:

//Predict the output

import java.util.Scanner;

public class Main

{

    public static void main(String args[])

    {

        StringBuilder str = new StringBuilder("Greatlife");

        int length = str.length();

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

    }

}

1
2
3
4

Solution:

Predict the output of the following Java code:

public class AbekusDatatype {
public static void main(String[] args) {
final long l1 = 13 * 245 * 189 * 5555 * 1234 * 10000;
final long l2 = 13 * 245 * 189 * 5555 * 1234;
System.out.println(l1 / l2);
}
}

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) throws IllegalStateException {

Queue<String> queue = new LinkedList<String>();

queue.add("a");

queue.add("f");

queue.add("b");

queue.add("x");

System.out.println(queue);

}

}

1
2
3
4

Solution: