Why we declare in the way List ab = new ArrayList(); what is the use of it?
Answer Posted / sravani gupta
When you declare List l = new ArrayList() l is limited to the methods provided by the interface List, while when you declare it ArrayList al = new ArrayList() it can use all methods and fields in an arraylist.
When you declare it List l then you afford yourself more flexibility as you can change out the ArrayList for something more appropriate at a later date if you want to without breaking any code
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
A trip takes 6 hours to complete. After traveling 1/4 of an hour, 1 3/8hours, and 2 1/3 hours, how much time does need to complete the trip? There are 30 socks in a drawer. 60% of the socks are red and the rest are blue. What is the minimum number of socks that must be taken from the drawer without looking in order to be certain that atleast two blue socks have been chosen?
The cost of one pencil, two pens and four erasers is Rs.22 while the cost of five pencils, four pens and two erasers is Rs.32.How much will three pencils, three pens and three erasers cost?
There are two trees in a lawn. One grows at a rate 3/5 of the other in 4 years. If the total growth of trees What is the height of the smaller tree after 2 years
The ratio between two numbers is 5:7 and their product is 560. What is the difference between these two numbers?
Ram, Shyam and Gumnaam are friends.Ram is a widower and lives alone and his sister takes care of him. Shyam is a bachelor and his niece cooks his food and looks after his house. Gumnaam is married to Gita and lives in large house in the same town. Gita gives the idea that all of them could stay together in the house and share monthly expenses equally. During their first month of living together, each person contributed Rs.25. At the end of the month, it was found that Rs 92 was the expense so the remaining amount was distributed equally among everyone. The distribution was such that everyone received a whole number of Rupees. How much did each person receive?
A person travels 6km towards west, then travels 5km towards north ,then finally travels 6km towards west. Where is he with respect to his starting position?
The average score of a cricketer for 13 matches is 42 runs. If his average score for the first 5 matches is 54, then what was his average score (in runs) for last 8 matches?
4^^61 + 4^^62 + 4^^63 + 4^^64 . this sum is divisible by which of the following ?
The time showed by the clock at a moment is 8 am then the respective time of after and before 42896 hours is :
Find the reminder when 333666777888999 divided by 3 or 9 or 11 ?
Find the nth number in the series is 1, -3, 5, -7.___
A man shapes 3 cardboards in 50 minutes,how many cardboards does he shape in 5 hours? answer 18cardboards.
Mr. Sohan works for Azania Company. The company grants 1000 shares to Mr. Sohan in 2008. At that point each share is worth Rs. 100. In 2010, he decides to sell his entire stake and at that point, the value is Rs. 120 per share. The government declares that the tax to be paid is 10% of the entire profit. Due to the inflation, the value of a rupee in 2010 is equivalent to 0.8 of a rupee in 2008. In this situation, which of the following model indicates the actual tax to be paid by the investor?
in a city, there are 100 buildings numbered by corporation between 0-100, how many twos are shown in door,
A bus started from bustand at 8.00am, and after staying for 30 minutes at a destination, it returned back to the busstand. The destination is 27 miles from the busstand. The speed of the bus is 18mph. During the return journey bus travels with 50% faster speed.At what time does it return to the busstand?