Questions On Java Basics

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Kowsalyavelusamy
K
Kowsalyavelusamy
Community Contributor
Quizzes Created: 1 | Total Attempts: 171
| Attempts: 171 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1.     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? 

Explanation

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

Submit
Please wait...
About This Quiz
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... see morequiz helps you practice on it. All the best. see less

2. Why is Java Architectural Neutral? 

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.

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

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.

Submit
4. Which one of these primitive types are unsigned?

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.

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

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.

Submit
6. 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?

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.

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

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.

Submit
8. Java supports both multi dimension and nested arrays.True/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.

Submit
9. GC is  a high  priority thread. True/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.

Submit
10. What is "Stop the World"? 

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

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

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
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
    public class GCTest3 {    GCTest3...
Why is Java Architectural Neutral? 
Programs designed for maintainability are constructed from small...
Which one of these primitive types are unsigned?
-XX:NewRatio=3: ,what does this mean?
If an object becomes eligible for Garbage Collection and its...
How Can you tell the system to perform a garbage collection? 
Java supports both multi dimension and nested arrays.True/False?
GC is  a high  priority thread. True/False?
What is "Stop the World"? 
Alert!

Advertisement