Podcast
Questions and Answers
What happens when an object is dynamically allocated using the new operator?
What happens when an object is dynamically allocated using the new operator?
What is the purpose of garbage collection?
What is the purpose of garbage collection?
What happens to byte, short, and char values in an expression?
What happens to byte, short, and char values in an expression?
What happens when an int value is assigned to a byte variable?
What happens when an int value is assigned to a byte variable?
Signup and view all the answers
What is the result of the expression byte t=100; int p=r * s / t
?
What is the result of the expression byte t=100; int p=r * s / t
?
Signup and view all the answers
What happens when a double value is assigned to an int variable?
What happens when a double value is assigned to an int variable?
Signup and view all the answers
What is the purpose of the garbage collector in Java?
What is the purpose of the garbage collector in Java?
Signup and view all the answers
Why is garbage collection necessary in Java?
Why is garbage collection necessary in Java?
Signup and view all the answers
What happens when an object is no longer referenced in Java?
What happens when an object is no longer referenced in Java?
Signup and view all the answers
What is the purpose of the finalize() method in Java?
What is the purpose of the finalize() method in Java?
Signup and view all the answers
When does garbage collection occur in Java?
When does garbage collection occur in Java?
Signup and view all the answers
Why is finalization necessary in Java?
Why is finalization necessary in Java?
Signup and view all the answers
What is the primary purpose of the finalize( ) method?
What is the primary purpose of the finalize( ) method?
Signup and view all the answers
What is the purpose of the protected specifier in the finalize( ) method?
What is the purpose of the protected specifier in the finalize( ) method?
Signup and view all the answers
What is the output of the following code: public class TestGarbage1 { public void finalize() { System.out.println("object is garbage collected"); } public static void main(String args[]) { TestGarbage1 s1=new TestGarbage1(); TestGarbage1 s2=new TestGarbage1(); s1=null; s2=null; System.gc(); } }
What is the output of the following code: public class TestGarbage1 { public void finalize() { System.out.println("object is garbage collected"); } public static void main(String args[]) { TestGarbage1 s1=new TestGarbage1(); TestGarbage1 s2=new TestGarbage1(); s1=null; s2=null; System.gc(); } }
Signup and view all the answers
What is the purpose of the System.gc() method?
What is the purpose of the System.gc() method?
Signup and view all the answers
What are command-line arguments in Java?
What are command-line arguments in Java?
Signup and view all the answers
How are command-line arguments stored in a Java program?
How are command-line arguments stored in a Java program?
Signup and view all the answers