Top 10 Java Interview Questions That Actually Tripped Quiz

Test your Java knowledge with this quiz featuring commonly asked Java interview questions and answers. Challenge yourself with important Java programming concepts, syntax, and tricky scenarios that often trip up even experienced developers.

  1. Primitive Data Types

    Which of the following is NOT a primitive data type in Java?

    1. boolean
    2. int
    3. String
    4. char
  2. Object Comparison

    Given two String objects with the same value, which operator correctly checks if their contents are equal in Java?

    1. equals()
    2. equals
    3. =equals
    4. ==
  3. Default Values

    What is the default value of an int variable in a Java class if it is not explicitly initialized?

    1. 1
    2. null
    3. -1
    4. 0
  4. Inheritance

    Which keyword is used in Java to inherit the properties of a class?

    1. import
    2. implements
    3. inherits
    4. extends
  5. Exception Handling

    If a method uses the 'throws' keyword, what is it indicating?

    1. It can throw an exception
    2. It is throwing a new object
    3. It is overriding a method
    4. It is skipping errors
  6. Array Indexing

    What happens if you try to access index 5 of a Java array with size 5, like arr[5]?

    1. It compiles successfully
    2. It throws an ArrayIndexOutOfBoundsException
    3. It returns 0
    4. It prints 'null'
  7. Final Keyword

    What does the 'final' keyword do when used to declare a variable in Java?

    1. Automatically initializes the variable
    2. Makes the variable constant
    3. Prevents the variable from being subclassed
    4. Makes the variable global
  8. Interfaces vs. Abstract Classes

    Which statement correctly distinguishes an interface from an abstract class in Java?

    1. Interfaces can provide implemented methods only
    2. Abstract classes do not support constructors
    3. An interface can have multiple inheritance, an abstract class cannot
    4. Interfaces can be instantiated
  9. Access Modifiers

    Which access modifier makes a Java class available only within the same package?

    1. private
    2. default
    3. protected
    4. public
  10. Polymorphism Example

    If class Dog extends class Animal and you write 'Animal a = new Dog();', which concept is being demonstrated?

    1. Polymorphism
    2. Encapsulation
    3. Abstraction
    4. Inheritance