Learn Functions Of Core Java

10 Questions | Total Attempts: 166

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

  • 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 };

  • 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.

  • 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

  • 5. 
    Whar is the Default Thread Priority?
    • A. 

      0

    • B. 

      10

    • C. 

      5

    • D. 

      1

  • 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';

  • 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

  • 8. 
    Can we force Garbage Collection(gc) ?
    • A. 

      Yes

    • 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.

  • 10. 
    Which will contain the body of the thread?
    • A. 

      Run();

    • B. 

      Main();

    • C. 

      Start();

    • D. 

      Stop();

Back to Top Back to top