Signup/Sign In

Interview MCQs Test for Core Java - Level 2

This Test will cover complete Java with very important questions, starting off from basics to advanced level.
Q. Which of these is not a bitwise operator?
Q. Which operator is used to invert all the digits in binary representation of a number?
Q. How can you stop the finally() block from executing, after try-catch block execution?

Q. What will happen when you attempt to compile and run the following code?
int Output = 10;
boolean b1 = false;
if((b1 == true) && ((Output += 10) == 20))
{
    System.out.println("We are equal " + Output);
}
else
{
    System.out.println("Not equal! " + Output);
}  
Q. Can you override private or static method in Java. Yes or No?
Q. Can you access non static variable in static context?
Q. What is the output of this program?
class bitwise_operator {
        public static void main(String args[])
        {
            int var1 = 42;
            int var2 = ~var1;
            System.out.print(var1 + " " + var2);     	
        } 
    }
Q. What is the output of this program?
class leftshift_operator {
        public static void main(String args[]) 
        {        
             byte x = 64;
             int i;
             byte y; 
             i = x << 2;
             y = (byte) (x << 2);
             System.out.print(i + " " + y);
        } 
    }
Q. What is the output of this program?
class selection_statements {
        public static void main(String args[])
        {
            int var1 = 5; 
            int var2 = 6;
            if ((var2 = 1) == var1)
                System.out.print(var2);
            else 
                System.out.print(++var2);
        } 
    }

Q. How do you ensure that N thread can access N resources without deadlock?
Q. What is the output of this program?
class comma_operator {
        public static void main(String args[]) 
        {    
             int sum = 0;
             for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)
                 sum += i;
 	     System.out.println(sum);
        } 
    }
Q. Java is designed for the distributed environment of the Internet, because it handles _________ protocols.
Q. Which of the following is not an exception in Java?
Q. Can you pass List<String> to a method which accepts List<Object>?
Q. What is the Output of this program?
class Output {
        public static void main(String args[]) 
        {    
             int x, y = 1;
             x = 10;
             if (x != 10 && x / 0 == 0)
                 System.out.println(y);
             else
                 System.out.println(++y);
        } 
    }

Related Tests: