Loading, please wait...

Core Java Multiple Choice Questions And Answers

Search here for MCQs

Are you preparing for the next job interviews? If yes, trust me this post will help you also we'll suggest you check out a big collection for Programming Full Forms that may help you in your interview:

List of Programming Full Forms 

6. Which two statements are reserved words in Java? (Choose Two)

  • Run
  • Import
  • Default
  • Implements

7. You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access modifier that will accomplish this objective?

  • Public
  • Private
  • Protected
  • Transient
  • No access modifier is qualified

8. Which gets the name of the parent directory file "file.txt"?

  • String name= File.getParentName("file.txt");
  • String name= (new File("file.txt")).getParent();
  • String name = (new File("file.txt")).getParentName();
  • String name= (new File("file.txt")).getParentFile();
  • Directory dir=(new File ("file.txt")).getParentDir(); String name= dir.getName();

9. Which constructs a DataOutputStream?

  • new DataOutputStream("out.txt");
  • new DataOutputStream(new File("out.txt"));
  • new DataOutputStream(new Writer("out.txt"));
  • new DataOutputStream(new FileWriter("out.txt"));
  • new DataOutputStream(new OutputStream("out.txt"));
  • new DataOutputStream(new FileOutputStream("out.txt"));

10. You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?

  • java.util.Map.
  • java.util.Set.
  • java.util.List.
  • java.util.SortedSet.
  • java.util.StoredMap.
  • java.util.Collection.