Logo

Java Questions Set 221:

Quiz Mode

Which of these is a wrapper class for the simple data type float?

1
2
3
4

Solution:

Which of these Exception handlers cannot be type parameterized?

1
2
3
4

Solution:

The command javac

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

   int x=10,y=15;

   if(x++<10 || --y>15)

   {

       x--;

   }

   else

   {

       y--;    

   }

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

}

}

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

   int x=10,y=15;

   if(x++<10 || --y>15)

   {

       x++;

   }

   else

   {

       y--;    

   }

   System.out.println(x+" "+(--y));

}

}

1
2
3
4

Solution:

What will be the output of the following Java code running with “java Abc I love to code”? 

public class Abc

{

   public static void main(String args[])

   {

        System.out.println(args[0]+""+args[args.length-1]);

   }

}

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

     int[] A=new int[2];

     int[] B=A;

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

     System.out.print(B[0]);

}

}

1
2
3
4

Solution:

Predict the output of the following Java code.

import java.util.*;

import java.util.stream.IntStream;

class Abekus {

public static void main(String[] args) {

IntStream i = IntStream.range(2, 5);

int j = i.peek(System.out::print).sum();

System.out.println(j);

}

}

1
2
3
4

Solution:

Predict the output of the following Java code.

class Abekus {

public static void main(String[] args)

{

int a1[] = new int[10];

int a2[] = new int['b'];

byte b = 15;

int a3[] = new int[b];

System.out.println(a1.length);

System.out.println(a2.length);

System.out.println(a3.length);

}

}

1
2
3
4

Solution:

What will be the output of the following Java program?

import java.io.*;

public class filesinputoutput

{

public static void main(String[] args)

{

String obj = "abc";

byte b[] = obj.getBytes();

ByteArrayInputStream obj1 = new ByteArrayInputStream(b);

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

{

int c;

while ((c = obj1.read()) != -1)

{

if (i == 0)

{

System.out.print(Character.toUpperCase((char)c));

}

}

System.out.println();

}

}

}

1
2
3
4

Solution: