Logo

Java Questions Set 31:

Quiz Mode

What will be the binary representation of the number 17 in Java?

1
2
3
4

Solution:

 

A synchronized method is applied to

1
2
3
4

Solution:

Setter and Getter used

1
2
3
4

Solution:

Predict the output of the following Java code.

1
2
3
4
5

Solution:

class test{

public static void main (String[] args) {

   int a=7|8;

   int b=0^a;

   System.out.println(b^15);

}

}

1
2
3
4

Solution:

public class j{

    public static void main(String args[]){

      String str = "12acf23df4fg34";

         System.out.println(str.replaceAll("\\d", ""));

    }

 }

1
2
3
4

Solution:

Which statement is correct about interfaces in Java?

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 is the output of this program?


    class Output 

    {

         public static void main(String args[]) 

        {

            double x = 2.1;  

            double y = 3.5;

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

            System.out.print(z);

        }

    }

1
2
3
4

Solution:

What will be the output of the following Java code?


class Output

{

public static void main(String args[])

{

long start, end;

start = System.currentTimeMillis();

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

end = System.currentTimeMillis();

System.out.print(end - start);

}

}

1
2
3
4

Solution: