Learn Functions Of Core Java

10 Questions | Attempts: 166
Share

SettingsSettingsSettings
Core Java Quizzes & Trivia

Questions and Answers
  • 1. 

    Which interface provides the capability to store objects using a key-value pair?

    • A.

      Java.util.Map

    • B.

      Java.util.List

    • C.

      Java.util.Set

    • D.

      Java.util.Collection

    Correct Answer
    A. Java.util.Map
  • 2. 

    Which one creates an instance of an array?

    • A.

      Float fa = new float[20];

    • B.

      Char[ ] ca = "Some String";

    • C.

      Int[ ] ia = new int[15];

    • D.

      Int ia[ ] [ ] = { 4, 5, 6 }, { 1,2,3 };

    Correct Answer
    C. Int[ ] ia = new int[15];
  • 3. 

    Which of the following statements about the hashcode() method are incorrect?

    • A.

      The value returned by hashcode() is used in some collection classes to help locate objects.

    • B.

      The hashcode() method is required to return a positive int value.

    • C.

      The hashcode() method in the String class is the one inherited from Object.

    • D.

      Two new empty String objects will produce identical hashcodes.

    Correct Answer
    B. The hashcode() method is required to return a positive int value.
  • 4. 

    Class Car { static int CarCount = 0; // Declare and initialize // static variable public Car() { CarCount += 1; // Modify the value in the constructor } public static void main (String [] args) { new Car(); new Car(); new Car(); System.out.println(CarCount); } } What is CarCount Value?

    • A.

      0

    • B.

      1

    • C.

      2

    • D.

      3

    Correct Answer
    D. 3
  • 5. 

    Whar is the Default Thread Priority?

    • A.

      0

    • B.

      10

    • C.

      5

    • D.

      1

    Correct Answer
    C. 5
  • 6. 

    Which is a invalid declarations of a String?

    • A.

      String s1 = null;

    • B.

      String s2 = new String("JavaStuff");

    • C.

      String s3 = "JavaStuff"

    • D.

      String s4 = (String) 'JavaStuff';

    Correct Answer
    D. String s4 = (String) 'JavaStuff';
  • 7. 

    Class Parent { public Parent(String s) { System.out.print("B"); } } public class Child extends Parent { public Child(String s) { System.out.print("D"); } public static void main(String [] args) { new Child("C"); System.out.println(" "); } }

    • A.

      DBC

    • B.

      DB

    • C.

      BD

    • D.

      Compilation fails

    Correct Answer
    C. BD
  • 8. 

    Can we force Garbage Collection(gc) ?

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
  • 9. 

    Which statement is true?

    • A.

      Any statement that can throw an Exception must be enclosed in a try block.

    • B.

      Any statement that can throw an Error must be enclosed in a try block.

    • C.

      The Error class is a RuntimeException.

    • D.

      Catch(X x) can catch subclasses of X where X is a subclass of Exception.

    Correct Answer
    D. Catch(X x) can catch subclasses of X where X is a subclass of Exception.
  • 10. 

    Which will contain the body of the thread?

    • A.

      Run();

    • B.

      Main();

    • C.

      Start();

    • D.

      Stop();

    Correct Answer
    A. Run();

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2022
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 12, 2011
    Quiz Created by
    Ram132
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.