PlacementPrep
Practice › Technical › CSE/IT › Java
Technical · CSE / IT

Java MCQs for placement tests

20 technical questions of moderate difficulty, as asked in campus placement and company tests. Each has a short explanation.

Q1CSE/IT · JavaModerate

What is the output of this Java program?

public class Main {
    public static void main(String[] args) {
        String a = new String("hi");
        String b = new String("hi");
        System.out.print((a == b) + " " + a.equals(b));
    }
}
Q2CSE/IT · JavaModerate

What is the output of this Java program?

public class Main {
    public static void main(String[] args) {
        String a = "hi";
        String b = "hi";
        System.out.print(a == b);
    }
}
Q3CSE/IT · JavaModerate

What is the output of this Java program?

public class Main {
    public static void main(String[] args) {
        System.out.print("" + 10 + 5);
    }
}
Q4CSE/IT · JavaModerate

What is the output of this Java program?

public class Main {
    public static void main(String[] args) {
        System.out.print(10 + 5 + "");
    }
}
Q5CSE/IT · JavaModerate

Which of these is NOT a primitive type in Java?

Q6CSE/IT · JavaModerate

What is the default value of an int instance variable in Java?

Q7CSE/IT · JavaModerate

Which keyword prevents a class from being inherited?

Q8CSE/IT · JavaModerate

Which statement about Java interfaces (Java 8 and later) is true?

Q9CSE/IT · JavaModerate

What is the output of this Java program?

class Animal { void sound() { System.out.print("Animal sound"); } }
class Dog extends Animal { void sound() { System.out.print("Dog barks"); } }
public class Main {
    public static void main(String[] args) {
        Animal a = new Dog();
        a.sound();
    }
}
Q10CSE/IT · JavaModerate

What is the output of this Java program?

public class Main {
    public static void main(String[] args) {
        try {
            int x = 5 / 0;
            System.out.print("Done ");
        } catch (ArithmeticException e) {
            System.out.print("Caught ");
        } finally {
            System.out.print("Finally");
        }
    }
}
Q11CSE/IT · JavaModerate

Which collection does NOT allow duplicate elements?

Q12CSE/IT · JavaModerate

Which method is the entry point of a Java application?

Q13CSE/IT · JavaModerate

What is the output of this Java program?

public class Main {
    public static void main(String[] args) {
        int[] a = {7, 8, 9};
        System.out.print(a.length);
    }
}
Q14CSE/IT · JavaModerate

What does the JVM do?

Q15CSE/IT · JavaModerate

Which keyword is used to call the parent class constructor?

Q16CSE/IT · JavaModerate

What is the output of this Java program?

public class Main {
    public static void main(String[] args) {
        System.out.print(5 / 2);
    }
}
Q17CSE/IT · JavaModerate

Which exception is thrown when accessing an index outside an array's bounds?

Q18CSE/IT · JavaModerate

In Java, Strings are:

Q19CSE/IT · JavaModerate

Which of these is a checked exception?

Q20CSE/IT · JavaModerate

What is the output of this Java program?

public class Main {
    public static void main(String[] args) {
        String s = "hello";
        System.out.print(s.toUpperCase());
    }
}

Want guided preparation? Placement Papers Prep courses by Dr. Kiran Derle, with video lessons and full-length mocks.

See placement courses ↗