Java Quiz: Test Your GK! Trivia

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By TeacheMeIDEA
T
TeacheMeIDEA
Community Contributor
Quizzes Created: 6 | Total Attempts: 16,226
Questions: 10 | Attempts: 1,007

SettingsSettingsSettings
Java Quiz: Test Your GK! Trivia - Quiz

.


Questions and Answers
  • 1. 

    What of the following is the default value of an instance variable?

    • A.

      Null

    • B.

      0

    • C.

      Depends upon the type of variable

    • D.

      Not assigned

    Correct Answer
    C. Depends upon the type of variable
    Explanation
    The default value of an instance variable depends upon the type of variable. In Java, the default value for numeric types (such as int, float, double) is 0, for boolean it is false, and for reference types (such as String) it is null. Therefore, the correct answer is "Depends upon the type of variable."

    Rate this question:

  • 2. 

    What is the size of the float variable?

    • A.

      8 bit

    • B.

      16 bit

    • C.

      32 bit

    • D.

      64 bit

    Correct Answer
    C. 32 bit
    Explanation
    The size of the float variable is 32 bits.

    Rate this question:

  • 3. 

    What is the default value of the String variable?

    • A.

      ''

    • B.

      ""

    • C.

      Null

    • D.

      Not defined

    Correct Answer
    C. Null
    Explanation
    The default value of a String variable is null. This means that if a String variable is not assigned a value, it will automatically have a null value.

    Rate this question:

  • 4. 

    Which of the following is true about public access modifier?

    • A.

      Variables, methods and constructors which are declared public can be accessed by any class.

    • B.

      Variables, methods and constructors which are declared public can be accessed by any class lying in same package.

    • C.

       Variables, methods and constructors which are declared public in the superclass can be accessed only by its child class.

    • D.

      None of the above.

    Correct Answer
    A. Variables, methods and constructors which are declared public can be accessed by any class.
    Explanation
    The public access modifier allows variables, methods, and constructors to be accessed by any class, regardless of whether they are in the same package or not. This means that any class, regardless of its location, can access and use the public members of a class. Therefore, the correct answer is that variables, methods, and constructors declared as public can be accessed by any class.

    Rate this question:

  • 5. 

    What is Abstraction?

    • A.

      Abstraction is a technique to define different methods of same type.

    • B.

      Abstraction is the ability of an object to take on many forms.

    • C.

      It refers to the ability to make a class abstract in OOP.

    • D.

      None of the above.

    Correct Answer
    C. It refers to the ability to make a class abstract in OOP.
    Explanation
    Abstraction in object-oriented programming (OOP) refers to the ability to make a class abstract. An abstract class is a class that cannot be instantiated and is meant to be subclassed. It provides a common interface for all the subclasses, but each subclass can have its own implementation. This allows for the concept of abstraction, where the essential details and behaviors of an object are captured in an abstract class, while the specific implementation details are left to the subclasses.

    Rate this question:

  • 6. 

    What is an applet?

    • A.

      An applet is a Java program that runs in a Web browser.

    • B.

      Applet is a standalone java program.

    • C.

      Applet is a tool.

    • D.

      Applet is a run time environment.

    Correct Answer
    A. An applet is a Java program that runs in a Web browser.
    Explanation
    An applet is a Java program that runs in a Web browser. This means that it is a small application written in the Java programming language that can be embedded within a web page and executed within a web browser. Applets are often used to provide interactive and dynamic content on websites, such as animations, games, or interactive forms. They have access to the browser's capabilities and can interact with the web page's HTML content. Applets are different from standalone Java programs, which are executed outside of a web browser.

    Rate this question:

  • 7. 

    What is NullPointerException?

    • A.

      A NullPointerException is thrown when calling the instance method of a null object or modifying/accessing field of a null object.

    • B.

      A NullPointerException is thrown when object is set as null.

    • C.

      A NullPointerException is thrown when object property is set as null.

    • D.

      None of the above.

    Correct Answer
    A. A NullPointerException is thrown when calling the instance method of a null object or modifying/accessing field of a null object.
    Explanation
    A NullPointerException is thrown when calling the instance method of a null object or modifying/accessing field of a null object. This means that if we try to perform any action on an object that is null (has no value assigned to it), such as calling a method or accessing a field, a NullPointerException will be thrown. This is because null objects do not have any methods or fields associated with them, so attempting to access them will result in an error.

    Rate this question:

  • 8. 

    What happens when the thread's yield() method is called?

    • A.

      Thread returns to the ready state.

    • B.

      Thread returns to the waiting state.

    • C.

      Thread starts running.

    • D.

      None of the above.

    Correct Answer
    A. Thread returns to the ready state.
    Explanation
    When the thread's yield() method is called, it temporarily pauses its execution and allows other threads of the same priority to run. It does not go back to the waiting state because it is not waiting for any specific condition or resource. Instead, it goes back to the ready state, where it is eligible to run again when the scheduler chooses it. This allows for fair scheduling and prevents a single thread from monopolizing the CPU.

    Rate this question:

  • 9. 

    Is it necessary that each try block must be followed by a final block?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    It is not necessary for each try block to be followed by a final block. A final block, also known as a finally block, is used to define a section of code that will always be executed, regardless of whether an exception is thrown or not. While it is a good practice to include a final block to handle any necessary cleanup operations, it is not mandatory. In some cases, the try block may be followed by catch blocks to handle specific exceptions, without the need for a final block.

    Rate this question:

  • 10. 

    Which of the following is a marker interface?

    • A.

      Serializable

    • B.

      Comparable

    • C.

      Cloneable

    • D.

      None of the above.  Show Answer

    Correct Answer
    A. Serializable
    Explanation
    A marker interface is an interface that does not contain any methods but is used to mark or tag a class. In this case, the correct answer is "serializable" because it is a marker interface in Java that indicates that a class can be serialized, meaning its objects can be converted into a byte stream for storage or transmission.

    Rate this question:

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 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 09, 2018
    Quiz Created by
    TeacheMeIDEA
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.