Logo

Java Questions Set 28:

Quiz Mode

Which of the following is not a bitwise operator

1
2
3
4

Solution:

T  parameters are used for a generic method to return and accept any type of object 

1
2

Solution:

 toArray(T[]a) : This method returns an array containing all of the elements in this list in proper sequence (from first to last element)

1
2

Solution:

public class abekus

{

public static void main(String[] args) {

  int arr[] = {1,2,3,4,5};

  int count = 0;

for(int i = 0 ; i<5; i++ ){

  if(arr[i]%2==0)

    count++;

}

System.out.print(count);

}

}

1
2
3
4

Solution:

 What will be the output of the following code ?

class

{

public static void main(String args[]) 

int a = 4;

int b = 6;

int c = a | b;

int d = a & b; 

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

}

1
2
3
4

Solution:

  Statement 1 -Array can be initialized using comma-separated expressions surrounded by curly braces
Statement 2 -Array can be initialized when they are declared 

1
2
3
4

Solution:

Which of the following statements about inheritance in Java is true?

1
2
3
4

Solution:

 public class outputs 

    {

        static int cube(int x){

          return x*x*x;

 

        } 

public static void main(String args[]){ 

    int result=outputs.cube(5);

 System.out.println(result);

}

}

1
2
3
4

Solution:

What is the output of this program?


    class Output 

    {

        public static void main(String args[]) 

        {

            double x = 103;

            double y = 5;

            double z = Math.IEEEremainder(x, y);

            System.out.print(z);}

         }

    }

1
2
3
4

Solution:

Predict the output of the following Java code:

class Abekus {

public static void main(String[] args) {

int String = 23;

int Runnable = 67;

int Thread = 88;

int RuntimeException = 90;

System.out.println(String + " " + Thread);

System.out.println(RuntimeException + " " + Runnable);

}

}

1
2
3
4

Solution: