Instruction

  • This test contains a total of 20 questions.
  • Do not switch the tab or open a new window, otherwise, the test will be submitted automatically.
  • Test time is 10 minutes.

Java Advance (Level 3)

Q 1.
Which of the following operators can operate on a boolean variable?
1. && 
2. == 
3. ?: 
4. +=

Q 2.
Which of these statements is correct?

Q 3.
What will be the output of the following Java code?
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);
    }
}

Q 4.
What will be the output of the following Java code?
class Output {
    public static void main(String args[]) {
        boolean a = true;
        boolean b = false;
        boolean c = a ^ b;
        System.out.println(!c);
    }
}

Q 5.
What would be the output of the following code snippet if variable a=10?
if (a <= 0) {
    if (a == 0) {
        System.out.println("1 ");
    } else {
        System.out.println("2 ");
    }
}
System.out.println("3 ");

Q 6.
What is true about do statement?

Q 7.
What is the valid data type for variable “a” to print “Hello World”?
switch (a) {
    System.out.println("Hello World");
}

Q 8.
From where break statement causes an exit?

Q 9.
Which of the following is not a valid flow control statement?

Q 10.
 Which of the following is a valid declaration of an object of class Box?

Q 11.
Which of these statement is incorrect?

Q 12.
What will be the output of the following Java program?
 class main_class 
    { 
        public static void main(String args[]) 
        { 
            int x = 9;
            if (x == 9)
            { 
                int x = 8;
                System.out.println(x);
            } 
        } 
    }

Q 13.
Which of the following statements is correct?

Q 14.
What will be the output of the following Java program?
 class box 
    {
        int width;
        int height;
        int length; 
    }
    class mainclass
    { 
        public static void main(String args[])
        {
            box obj = new box();
            obj.width = 10; 
            obj.height = 2;
            obj.length = 10; 
            int y = obj.width * obj.height * obj.length; 
            System.out.print(y); 
        } 
    }

Q 15.
What will be the output of the following Java program?
 class box 
    { 
        int width;
        int height;
        int length;
    }
    class mainclass
    {
        public static void main(String args[]) 
        { 
            box obj1 = new box(); 
            box obj2 = new box(); 
            obj1.height = 1; 
            obj1.length = 2;
            obj1.width = 1; 
            obj2 = obj1;
            System.out.println(obj2.height);
        } 
    }

Q 16.
 What will be the output of the following Java program?
class box 
    { 
        int width;
        int height; 
        int length; 
    }
    class mainclass 
    { 
        public static void main(String args[]) 
        {
            box obj = new box(); 
            System.out.println(obj);
        } 
    }

Q 17.
What is -Xms and -Xmx while starting jvm?

Q 18.
What happens to the thread when garbage collection kicks off?

Q 19.
Which of the below is not a memory leak solution?

Q 20.
Garbage Collection can be controlled by a program?


Time: