Logo

Java Questions Set 20:

Quiz Mode

________() method is used to concatenate two strings.

Solution:

Which Java class is used to read and write bytes in a file?

1
2
3
4

Solution:

Which of these processes occur automatically by the Java runtime system?

1
2
3
4

Solution:

Which of these methods return localized description of an exception?

1
2
3
4

Solution:

What is a marker interface?

1
2
3
4

Solution:

Which of the following is used to read objects from a stream?

1
2
3
4

Solution:

How many copies of static and instance variables are created when 10 objects are created of a class?

1
2
3
4

Solution:

what should be the output of this code block?

public class abekus {

 public static void main(String[] args) {

  int a = 5;

  a += 5;

  switch (a) {

  case 5:

   System.out.print("5");

   break;

  case 10:

   if (a % 2 == 0)

    System.out.print("even");

   else

    System.out.print("odd");

   break;

  default:

   System.out.print("0-2");

  }

 }

}

1
2
3
4

Solution:

What is the output of the following program?

  class A

    {

        public static void main(String args[]) 

        {    

             boolean a = true;

             boolean b = false;

             boolean c = a | b;

      boolean d = a & b;

             System.out.println(c + " " + d);

        } 

    }

1
2
3
4

Solution:

What will be the output of the following Java program?


import java.io.*;

class CharArrayInput

{

public static void main(String[] args)

{

String obj = "abcdefgh";

int length = obj.length();

char c[] = new char[length];

obj.getChars(0, length, c, 0);

CharArrayReader input1 = new CharArrayReader(c);

CharArrayReader input2 = new CharArrayReader(c, 1, 4);

int i;

int j;

try

{

while ((i = input1.read()) == (j = input2.read()))

{

System.out.print((char)i);

}

}

catch (IOException e)

{

e.printStackTrace();

}

}

}

1
2
3
4

Solution: