Menu
Question Index
...

How many objects will be eligible for garbage collection after line 7?

public class CountOfObjects {
    public static void main(String[] args) {
        Object first = new Integer(25); // Line1
        Object second = new Long(100); // Line2
        Object third = new String("100"); // Line3
        first = null; // Line4
        first = third; // Line5
        third = second; // Line6
        second = first; // Line7
    }
}


2
3
0
1
Compilation Error or Runtime Error

Doubts

Problems

Topic: Object As A Super Class In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App