Why we declare in the way List ab = new ArrayList(); what is the use of it?



Why we declare in the way List ab = new ArrayList(); what is the use of it?..

Answer / 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

More General Aptitude Interview Questions

What is the average candidates who appeared from state q during the given years?

0 Answers  


out of three numbers first is twice the second and is half of third.if the average of the 3 number is 56 the three no. in order are

3 Answers  


Hi, Can anybody please send me the last year question papers of Oriental Bank of Commerce PO exam. My email ID is: yamini.friend14@gmail.com Thanks.

0 Answers  


ques-- fint the sum of series- 1!+2!+....50!=?...

1 Answers   TCS,


A hotel has two,the east wing and the west wing.some east wing rooms but not all have an ocean view(OV).All WW have a harbour view(HV).The charge for all rooms is identical, except as follows * Extra charge for all HV rooms on or above the 3rd floor * Extra charge for all OV rooms except those without balcony * Extra charge for some HV rooms on the first two floor&some EW rooms without OV but having kitchen facilities.

0 Answers   Infosys,






There are Brown and Black cows. In five days four black cows and 3 brown cows give as mush as milk that four brown cows and 5 black cows give in four days. If the black cow gives 10 litres of milk per day, how many liters of milk the Brown cow will give in one day? (Numbers are not certain)

0 Answers   Accenture,


Argentina had football team of 22 player of which captain is from Brazilian team and goalki from European team. For remainig player they have picked 6 from argentinan and 14 from european. Now for a team of 11 they must have goalki and captain so out of 9 now they plan to select 3 from argentinian and 6 from European. Find out no. of methods avilable for it

0 Answers   Cognizant,


PlZ Send me the Banking(Axis) Sector Question paper to my id?

0 Answers  


BOTH WHICH TEAM IN FINAL IPL 2009 & WHO IS WIN

7 Answers  


A beats B by 10 meters and B beats C by 15 meters the A beats C by

0 Answers   Accenture,


If the produtof the 4 consecutive integers is equal to one of them what is the largest possible value of one of the integers

3 Answers  


(1/2) of a number is 3 times more than the (1/6) of the same number?

0 Answers   TCS,


Categories