Logo

Java Questions Set 197:

Quiz Mode

Which constructor is used to create an empty String object?

1
2
3
4

Solution:

The method used to clear all data present in output buffers is 

1
2
3
4

Solution:

Which class is at the top of the Java event class hierarchy?

1
2
3
4

Solution:

Which of these types cannot be used to initiate a generic type?

1
2
3
4

Solution:

public class operator {

  public static void main(String[] args)

  {

    int a = 40, b = 20, c = 35, output;

    output = ((a < b) ? (a < c) ? a : c : (b < c) ? b : c);

    System.out.println(output);

  }

}

1
2
3
4

Solution:

What is the output of the following Java code?


public class Test {

public static void main(String[] args) {

int x = 4;

int y = x++;

System.out.print(x + " " + y);

}

}

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

        byte x = 4;

             int i;

             byte y; 

             i = x >> 2;

             y = (byte) (x << 2);

             System.out.print(i + " " + y);

}

}

1
2
3
4

Solution:

What is the output of the following Java code?

class Main

{

  public static void main(String[] args)

  {

     int sum=0;

     for(int i=0,j=0; i<5 && j<5 ; i++,j=i+1)

     {

        sum+=i;

     }

     System.out.println(sum);

  }

}

1
2
3
4

Solution:

Select the correct option for the following Java code.

import java.io.*;

class Abekus {

public static void main (String[] args) {

byte a = 20; // line 1

byte b = 30; // line 2

a++;         // line 3

b=b+1;       // line 4

byte c = a+b;// line 5

System.out.println(c);

}

}

1
2
3
4

Solution: