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
Consider a pile of Diamonds on a table.A thief enters and steals 1/2 of th e total quanity and then again 2 extra from the remaining. After some time a second thief enters and steals 1/2 of the remaining+2. Then 3rd thief enters and steals 1/2 of the remaining+2.Then 4th thief enters and steals 1/2 of the remaining+2.When the 5th one enters he finds 1 diamond on the table.Find out the total no. of diamonds originally on the table before the 1st thief entered.
A says Party was held on :Thursday ,May 8th. B says Party was held on :Tuesday,May 10th. C says party was held on :Friday ,June 8th. Given April 1 st was Tuesday.one of A,B,C says 1 correct.one says 1 wrong.and one was completely wrong of date,Month and day. Find the Day the party held.
There is a certain four digit number whose fourth digit is twise the first digit. Third digit is three more than second digit. Sum of the first and fourth digits twise the third number. What was that number ?
If a square is formed by the diagonal of the square as an edge, what is the ratio between the area?
The length and breadth of a rectangle are increased by 20% and 40% respectively. What is the percentage increase in its area?
the ticket sales s for a company increases 25% from standard sales to 60 tickets sold, then 60 - s =:
A man has Rs 2. He wins or loses Re 1 at a time. If he wins he gets Re 1 and if he loses the game he loses Re 1. He can loose only 5 times. He is out of the game if he earns Rs 5.Find the number of ways in which this is possible?
There are three types of tickets available for a concert: orchestra , which cost $12 each; balcony, which cost$9 each: and box, which cost $25 each. There were P orchestra tickets , B balcony tickets, and R box tickets sold for the concert. Which of the following expressions gives the percentage of ticket proceeds due to the sale of orchestra tickets?
What is the average candidates who appeared from state q during the given years?
If ABC =C3C3 and CAB = D3D3, Then find D3÷B3D3÷B3
two trains are 2 kms apart. Speed of one train is 20m/s and the other train is running at 30 m/s. Lengths of the trains are 200 and 300m. In how much time do the trains cross each other?
A plane moves from 9? N40? E to 9? N40? W. If the plane starts at 10 am and takes 8 hours to reach the destination, find the local arrival time.
6 Face of a cube are painted in a manner ,no 2 adjacent face have same colour three colurs used are red blue green. Cube is cut in to 36 smaller cube in such a manner that 32 cubes are of one size and rest of them bigger size and each bigger side have no red side.
There six red shoes & 4 green shoes .If two of the shoes are drawn.What is the probability of getting two red shoes.
A monkey starts climbing up a tree 20ft. tall. Each hour, it hops 3ft. and slips back 2ft. How much time would it take the monkey to reach the top?