Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What will be the output of the program?

public class Test {
public static void main(String args[]) {
ArrayList<String> list = new ArrayList<String>();
list.add("2");
list.add("3");

list.add("4");
list.add("5");
System.out.println("size :"+list.size());
for(int i=0;i<list.size();i++) {
list.remove(i);
}
System.out.println("size after:"+list.size());
}
}

Answer Posted / ggpune

Output will be
size :4
Size after: 2

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define how can we find the actual size of an object on the heap?

1115


If you do not want your class to be inherited by any other class. What would you do?

947


How we can skip finally block of exception even if some exception occurs in the exception block in java?

882


What is polymorphism java example?

941


What do you understand by the term polymorphism?

1005


What is the difference between jdk and jre?

1007


Does collectionutils isempty check for null?

1374


Can we create a class inside a class in java?

994


What are static variables and functions?

1063


What is derived datatype?

1153


a thread is runnable, how does that work? : Java thread

930


Explain importance of inheritance in java?

966


How big is a 64 bit float?

953


How do you sort words in java?

881


Why is string buffer better than string ?

1041