What Will Be The Output Of The Following Java Codep Pre #601
What will be the output of the following Java code?</p> <pre><code class="language-java"> class FinaliseObject { public void finalize() { System.out.println("This is the finalize() method "); } public static void main(String[] args) { String str = new String("Hi, Welcome in Java World"); str = null; System.gc(); System.out.println("This is finalize class"); } } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs111 OOP Object Oriented Programming Java. It can also be found in gs gs111 Types of Classes (Using Java) - Object Class - Quiz No.1.
What will be the output of the following Java code?
class FinaliseObject { public void finalize() { System.out.println("This is the finalize() method "); } public static void main(String[] args) { String str = new String("Hi, Welcome in Java World"); str = null; System.gc(); System.out.println("This is finalize class"); } }
This is the finalise() method
Hi, Welcome in Java World
This is finalize class
Compilation error