How many objects will be created in this case string s=”ab”+”cd”+”ef” in java?

class NumberOfObjects

{

                public static void main(String arg[])

                {

                                String s="ab"+"cd"+"ef";

                                //Number of Objects = 5

                                System.out.println(s);

                }

}

Number of objects in java.PNG

, , , , , ,

Leave a Reply