Home > MCQs > IT & Programming > Core Java MCQs

Core Java MCQ

Core Java Quick Quiz

Question 1 of 10
  • In your program, you need to read a zip file (myfile.zip) containing several other data files containing basic Java objects. Which of the following will allow you to construct a InputStream for the task?

    Answer & Explanation

    Correct Answer: new ObjectInputStream(new ZipInputStream( new FileInputStream((“myfile.zip”)));

    Note: This Question is unanswered, help us to find answer for this one

  • Float p = new Float(3.14f); if (p > 3) { System.out.print("p is bigger than 3. "); } else { System.out.print("p is not bigger than 3. "); } finally { System.out.println("Have a nice day."); } What is the result?

    Answer & Explanation

    Correct Answer: Compilation fails.

    Note: This Question is unanswered, help us to find answer for this one

  • What will be the output of the program? public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( "Finally" ); } } }

    Answer & Explanation

    Correct Answer: Finally

    Note: This Question is unanswered, help us to find answer for this one

  • Given a class containing the following pieces of code: ---------------------- public static <T> List getList() { return new ArrayList<T>(); } // ... List<?> list = new ArrayList<Integer>(); ---------------------- Adding which of the following lines would cause the class to not compile?

    Answer & Explanation

    Correct Answer: List<Integer> list2 = list;

    Note: This Question is unanswered, help us to find answer for this one

  • java.util.Collection is:

    Answer & Explanation

    Correct Answer: An interface for iterable groups of objects

    Note: This Question is unanswered, help us to find answer for this one

  • Does interrupt() always force all threads to terminate?

    Answer & Explanation

    Correct Answer: No, if the interruption is not enabled for the thread, it will not terminate

    Note: This Question is unanswered, help us to find answer for this one

  • All of the classes in the Java Collections Framework:

    Answer & Explanation

    Correct Answer: Have methods to retrieve their data as an Array

    Note: This Question is unanswered, help us to find answer for this one

  • The data members of interface in java are:

    Answer & Explanation

    Correct Answer: public static final

    Note: This Question is unanswered, help us to find answer for this one

  • Which class/classes is/are thread safe among these?

    Answer & Explanation

    Correct Answer: String and StringBuffer

    Note: This Question is unanswered, help us to find answer for this one

  • The TreeMap and LinkedHashMap classes:

    Answer & Explanation

    Correct Answer: Enable iteration of a map's entries in a deterministic order.

    Note: This Question is unanswered, help us to find answer for this one

  • Core Java Quick Quiz

    battery

    Poor Results!

    You need a lot of improvement.

    Just don't give up!

    Correct Answers: 0/10

    Start Practicing with our MCQs given below.