Logo

Java Questions Set 176:

Quiz Mode

java.lang.security package is used for handling security-related issues in a program 

1
2

Solution:

Which of the following blocks executes  compulsorily whether an exception is caught or not

1
2
3
4

Solution:

Which provides runtime environment for java byte code to be executed?

Solution:

public class Main {

 public static void main(String[] args) {

  String txt = "Hello World";

  System.out.println(txt.toUpperCase());

 }

}

1
2
3
4

Solution:

You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

       int a,b,c,d;

            a=b=c=d=40;

            a+=b-=c*=d/=20;

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

}

}

1
2
3
4

Solution:

Statement 1 - Integer takes 4 bytes of memory.

Statement 2 - Integer takes 32 bits of memory.

 Statement  3 - Integer takes 6 bytes of memory.

1
2
3
4

Solution:

public class output 

    {

         public static void main(String args[]) 

        {

            double a = 4.5;  

            double b = 5.5;

            double c = Math.min( a, b );

            System.out.print(c);

        }

    }

1
2
3
4

Solution:

What will be the output of the following program?

class A

    {

        public static void main(String args[])

        {

            int a = 10; 

            int b = 20;

            int c;

            c = ++b - b / a + a;

            System.out.print(c);

        } 

    }

1
2
3
4

Solution:

Predict the output of the following Java code.

public class Abekus {

public static void main(String[] args) {

StringBuilder s1 = new StringBuilder("Amrit ");

String s2 = "Anand";

s1.append(s2);

s1.substring(8);

int i = s1.indexOf(s2);

System.out.println(i);

}

}

1
2
3
4

Solution: