Basics Of Core Java

50 Questions | Total Attempts: 140

SettingsSettingsSettings
Please wait...
Core Java Quizzes & Trivia

Simple Quiz based on basics of Core Java covering almost all important aspects of programming language. Make sure to come out with flying colors. Passing: 80%Time: 30 Minuteswww. Java-interviewer. Blogspot. Com


Questions and Answers
  • 1. 
    You would use Java because?
    • A. 

      It is platform independant

    • B. 

      It follows OOPs

    • C. 

      It is Open Source

  • 2. 
    What does WORA stands for?
    • A. 

      Wear Ornaments, Run Anywhere

    • B. 

      Write Once, Run Anywhere

    • C. 

      Write Once, Read Again

    • D. 

      Write Only, Read Only

  • 3. 
    Which of the following access restriction is more restricted than others?
    • A. 

      Public

    • B. 

      Private

    • C. 

      Protected

    • D. 

      Default

  • 4. 
    Java is pass by value. True or False?
    • A. 

      True

    • B. 

      False

  • 5. 
    Which of the following is NOT an example of RuntimeException
    • A. 

      NullPointerException

    • B. 

      NumberFormatException

    • C. 

      ArrayIndexOutOfBoundException

    • D. 

      FileNotFoundException

  • 6. 
    Can I restart a thread after it's lifecycle is complete?
    • A. 

      Yes, You can

    • B. 

      No, You can not. It will give you IllegalThreadStateException if you try to restart a dead thread.

  • 7. 
    If Class Employee extends Class Person, Which of the below statements can I write below statement using generics? 
    • A. 

      List< Person > list = new ArrayList< Person >();

    • B. 

      List< Employee > list = new List< Employee >();

    • C. 

      List< Employee > list = new ArrayList< Person >();

    • D. 

      List< Person > list = new ArrayList< Employee >();

  • 8. 
    Generics are used for Compile Time Type Safety. True or False?
    • A. 

      True

    • B. 

      False

  • 9. 
    How to iterate over a List?List<String> list = new ArrayList<String> ();  
    • A. 

      For (String s : list) {....}

    • B. 

      Iterator iterator = list.iterator(); while(iterator.hasNext()){ System.Out.println(iterator.next()); }

  • 10. 
    Which of the following is NOT used for iteration purposes?
    • A. 

      For

    • B. 

      While

    • C. 

      Do while

    • D. 

      Switch

  • 11. 
    Which keyword is used to instantiate an object of a class?
    • A. 

      Final

    • B. 

      New

    • C. 

      Volatile

    • D. 

      Super

  • 12. 
    Objects and instance variables are stored on Heap while method variables are stored on a stack. True or False?
    • A. 

      True

    • B. 

      False

  • 13. 
    What are differences between Hashtable and HashMap?
    • A. 

      Hashtable is synchronised while HashMap is not

    • B. 

      HashMap is faster than Hashtable

  • 14. 
    Which of the following is not a method of Object class?
    • A. 

      Equals

    • B. 

      Hashcode

    • C. 

      ToString

    • D. 

      Clone

    • E. 

      Wait

    • F. 

      Run

  • 15. 
    Object is the parent class of every class. True or False?
    • A. 

      False

    • B. 

      True

  • 16. 
    What is a marker interface?
    • A. 

      An interface who do not have any methods

    • B. 

      JVM gives special treatment to such interfaces

    • C. 

      Clonable, Serializable are some examples of marker interface

  • 17. 
    What is the difference between calling run method and calling start method on a thread?
    • A. 

      There is no difference

    • B. 

      Run method will just execute the code in main method while start method will actually execute the code in new thread

    • C. 

      Start method will just execute the code in main method while run method will actually execute the code in new thread

  • 18. 
    How to create a thread in Java?
    • A. 

      By extending Thread class

    • B. 

      By implementing Runnable interface

    • C. 

      By implementing Threadable interface

  • 19. 
    Which of the JCF API will you use if you do want sorted non duplicate elements?
    • A. 

      TreeSet

    • B. 

      TreeMap

    • C. 

      LinkedList

    • D. 

      LinkedHashSet

  • 20. 
    Which of the following is an example of Ordered List?
    • A. 

      LinkedList

    • B. 

      ArrayList

    • C. 

      Vector

    • D. 

      HashSet

  • 21. 
    Set does not allow duplicate elements. True or False?
    • A. 

      True

    • B. 

      False

  • 22. 
    Which one is faster?
    • A. 

      Vector

    • B. 

      ArrayList

  • 23. 
    LinkedList implements which interfaces?
    • A. 

      List

    • B. 

      Queue

    • C. 

      Map

    • D. 

      Set

  • 24. 
    Which of the following interfaces extend Collection interface?
    • A. 

      List

    • B. 

      Set

    • C. 

      Map

    • D. 

      Queue

  • 25. 
    What would be the return value of below method?public static int getValue(){ int i = 10; if (i >= 5){ return 100; }else if(i <= 11){ return 11; }else{ return 0; } }
    • A. 

      100

    • B. 

      11

    • C. 

      0

Back to Top Back to top