Questions On Java Basics

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 Kowsalyavelusamy
K
Kowsalyavelusamy
Community Contributor
Quizzes Created: 1 | Total Attempts: 170
Questions: 10 | Attempts: 171

SettingsSettingsSettings
Java Quizzes & Trivia

Java is one of the most used programs by nerds and techs in the world today. If you are one of them, you know practice is key. This quiz helps you practice on it. All the best.


Questions and Answers
  • 1. 

    Programs designed for maintainability are constructed from small simple pieces or modules. Modules in Java are called:

    • A.

      A.methods.

    • B.

      B.classes.

    • C.

      C.arguments.

    • D.

      D.both methods and classes.

    Correct Answer
    D. D.both methods and classes.
    Explanation
    Programs designed for maintainability are constructed from small simple pieces or modules. In Java, these modules are called classes. Classes are used to define the structure and behavior of objects in a program. Additionally, methods are also essential components of a program as they contain the code that performs specific tasks or operations. Therefore, both methods and classes play a crucial role in creating maintainable programs in Java.

    Rate this question:

  • 2. 

    Which one of these primitive types are unsigned?

    • A.

      Char

    • B.

      Long

    • C.

      Double

    • D.

      Float

    Correct Answer
    A. Char
    Explanation
    The correct answer is char because it is the only primitive type that can represent unsigned values. The other options, long, double, and float, are all signed types.

    Rate this question:

  • 3. 

    GC is  a high  priority thread. True/False?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    GC (Garbage Collection) is not a high priority thread. It is a background process that is responsible for reclaiming memory occupied by objects that are no longer in use by the program. The priority of the GC thread is typically lower than that of the application threads, as the main focus is on executing the application logic efficiently. Therefore, the correct answer is False, indicating that GC is not a high priority thread.

    Rate this question:

  • 4. 

    Java supports both multi dimension and nested arrays.True/False?

    • A.

      False

    • B.

      True

    Correct Answer
    A. False
    Explanation
    Java supports multi-dimensional arrays, which are arrays of arrays. This means that an array in Java can have multiple dimensions, such as a 2-dimensional array or a 3-dimensional array. However, Java does not support nested arrays, which are arrays that are elements of another array. In other words, Java does not allow arrays to be nested inside each other. Therefore, the correct answer is False.

    Rate this question:

  • 5. 

    If an object becomes eligible for Garbage Collection and its finalize() method has been called and inside this method the object becomes accessible by a live thread of execution and is not garbage collected. Later at some point the same object becomes eligible for Garbage collection, will the finalize() method be called again?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    If an object becomes eligible for Garbage Collection and its finalize() method has been called and inside this method the object becomes accessible by a live thread of execution and is not garbage collected, the finalize() method will not be called again when the object becomes eligible for garbage collection again. Once the finalize() method has been called and the object has been determined to be not garbage collected, it will not be called again in future garbage collection cycles.

    Rate this question:

  • 6. 

        public class GCTest3 {    GCTest3 g;        public static void main(String [] str){         GCTest3 gc1 = new GCTest3();        GCTest3 gc2 = new GCTest3();        gc1.g = gc2; //gc1 refers to gc2        gc2.g = gc1; //gc2 refers to gc1        gc1 = null;        gc2 = null;        }     }                                  Which Object is eligible for garbage collection? 

    • A.

      Gc1

    • B.

      Gc2

    • C.

      Gc1 and gc2

    • D.

      GCTest3

    Correct Answer
    C. Gc1 and gc2
    Explanation
    The objects gc1 and gc2 are eligible for garbage collection because they are no longer referenced by any variables in the program.

    Rate this question:

  • 7. 

    Why is Java Architectural Neutral? 

    • A.

      Because it supports Object Oriented Concepts

    • B.

      Because it provides powerful exception handling mechanisms

    • C.

      Because it is Platform Independent

    • D.

      Because it supports Multi-threading

    Correct Answer
    C. Because it is Platform Independent
    Explanation
    Java is considered architectural neutral because it is platform independent. This means that Java programs can run on any operating system or hardware platform without the need for any modifications. Java achieves this through the use of the Java Virtual Machine (JVM), which acts as an intermediary between the Java code and the underlying system. The JVM interprets the Java bytecode and converts it into machine code that can be executed by the specific operating system and hardware. This allows Java programs to be written once and run anywhere, making it highly portable and adaptable to different environments.

    Rate this question:

  • 8. 

    What is "Stop the World"? 

    • A.

      When GC occurs ,the thread where the collection occures should be interrupted.

    • B.

      Application suspended because of deadlock

    • C.

      Both A and B

    • D.

      None of the above

    Correct Answer
    A. When GC occurs ,the thread where the collection occures should be interrupted.
    Explanation
    "Stop the World" refers to a pause in the execution of an application when garbage collection (GC) occurs. During GC, the thread responsible for garbage collection interrupts the execution of the application in order to reclaim memory occupied by objects that are no longer needed. This interruption is necessary to ensure the consistency of the memory state during garbage collection. Therefore, the correct answer is "When GC occurs, the thread where the collection occurs should be interrupted."

    Rate this question:

  • 9. 

    -XX:NewRatio=3: ,what does this mean?

    • A.

      Set the size of Eden space relative to the size of a survivor space.

    • B.

      Set the size of the Young Generation as a ratio of the size of the Old Generation

    • C.

      Set the size of survivor space relative to the size of a Old Generation

    • D.

      None of the above.

    Correct Answer
    B. Set the size of the Young Generation as a ratio of the size of the Old Generation
    Explanation
    This option suggests that the XX:NewRatio parameter is used to set the size of the Young Generation in relation to the size of the Old Generation. It implies that by adjusting this ratio, one can control the memory allocation for the different generations in Java garbage collection.

    Rate this question:

  • 10. 

    How Can you tell the system to perform a garbage collection? 

    • A.

      System.gc();

    • B.

      Garbage colelction can't be forced

    • C.

      RunTime.gc();

    • D.

      System.gc() and RunTime.gc()

    Correct Answer
    D. System.gc() and RunTime.gc()
    Explanation
    The correct answer is system.gc() and RunTime.gc(). These two methods can be used to suggest the system to perform a garbage collection. The system.gc() method is a static method of the System class that suggests the JVM to perform garbage collection. The RunTime.gc() method is a method of the Runtime class that suggests the JVM to run the garbage collector. Both methods can be used to suggest the JVM to perform garbage collection, although it is not guaranteed that the garbage collection will actually occur immediately.

    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 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 04, 2015
    Quiz Created by
    Kowsalyavelusamy
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.