Java

Java

Test your Java knowledge with free quizzes on MyCodeSkills covering core concepts.


  1. Which of these is used to compile Java code?

    • javac
    • java
    • javadoc
    • javap
  2. Which of the following is not a Java feature?

    • Object-oriented
    • Platform independent
    • Use of pointers
    • Robust
  3. Which keyword is used to define a class in Java?

    • object
    • def
    • class
    • new
  4. What is the default value of an int variable in Java?

    • 0
    • null
    • 1
    • undefined
  5. Which of the following is a valid identifier in Java?

    • 2value
    • value_2
    • value-2
    • value 2
  6. Which concept allows multiple methods with the same name but different parameters?

    • Inheritance
    • Polymorphism
    • Overloading
    • Overriding
  7. Which access modifier makes a member visible only within its package?

    • public
    • protected
    • private
    • default
  8. Which interface does HashMap implement?

    • List
    • Map
    • Set
    • Queue
  9. Which collection does not allow duplicate elements?

    • List
    • Map
    • Set
    • Queue
  10. Which class is immutable in Java?

    • String
    • StringBuilder
    • StringBuffer
    • ArrayList
  11. Which method in Object class is used for garbage collection request?

    • delete()
    • dispose()
    • finalize()
    • collect()
  12. Which API is used for functional-style operations in Java?

    • Collections API
    • Stream API
    • IO API
    • Thread API
  13. Which keyword is used to define a lambda expression parameter type explicitly?

    • val
    • var
    • explicit
    • No keyword required
  14. Which of these is not a state of a thread?

    • Running
    • Waiting
    • Sleeping
    • Terminated
  15. Which collection class is best suited for implementing LRU cache?

    • HashSet
    • LinkedHashMap
    • TreeMap
    • Vector