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

A ship started from port and moving with 'I' miles/hour and other ship started From L and moving with 'H' miles/hour . At the place where these two ships will meet?

2 Answers   Accenture, TCS,


Direction for Qn 1-8 Ans A using I only Ans B using II only Ans C using both I and II Ans D not solvable 1. Raman and Gaurav Brought eggs from a vendor. How many eggs were bought by each of them i. Raman bought half as many as Gaurav ii. The dealer had a stock of 500 eggs at the beginning of day 2. What is the age of Ramprakash? i. Ramprakash was born when his father was 26 yrs old ii. Ramprakash's mothers age is 3yrs less than his father's 3. How much time is reqd for downloading the software? i. The Data transfer rate is 6 kbps ii. The size of the software is 4.5 megabytes 4. Sanjay and Vijay started their journey from Mumbai to Pune. Who reached Pune first? i. Sanjay overtakes two times Vijay and Vijay overtakes Sanjay two times ii. Sanjay started first 5. Is the GDP of country X higher than Country Y? i. GDP's of X and Y has been increasing at a compounded annual growth rate of 5% and 6% over he past 5 yrs ii. 5 yrs ago GDP of X was 1.2 times Y 6. A boat can ferry 1500 passengers across a river in 12 hrs. How many round trips does it make during the journey? i. The boat can carry 400 passengers at a time ii. During its journey, the boat takes 40 mins time each way and 20 mins waiting time at each end. 7. What are the values of m and n? i. n is an even integer, m is odd integer and m is greater than n. ii. The product of m and n is 30 8. How much is the weight of 20 mangoes and 30 oranges? i. 1 orange weighs twice that of 1 mango ii. 2 mangoes and 3 oranges weigh 2 kg

0 Answers  


Each row of letters or numbers has a rule connecting them. Write the next number or letterin the brackets. N , O , M , P , L , Q , K , R , (_ _ _)

0 Answers   Accenture,


A cistern can be filled by two pipes in 30 an 40 min, respectively. ... How long after the pipes have been turned on, the first one was turned off?

1 Answers  


Pipe A can fill a tank in 30 mins and Pipe B can fill it in 28 mins.If 3/4th of the tank is filled by Pipe B alone and both are opened, how much time is required by both the pipes to fill the tank completely ?

0 Answers   3i Infotech, Amazon, Canara Bank, Mu Sigma,






Sir, I'm sonjoy bhadra, plz send me previous 10 years solved question papers for sbi clarical exam and also send one model paper pattern for this year

0 Answers  


If a clerk can process 80 cheques in half an hour, how many cheques can she process in a seven and one half hour day?

8 Answers   TCS,


A and B can do a piece of work in 72 days; B and C can do it in 120 days; A dn C can do it in 4 days. Who among these will take the least time if put to do it alone?

7 Answers   Loco Pilot, Wipro,


present ages of sameer and anand are in the ratio of 5 : 4 respectively. Three years hence, the ratio of their ages will become 11 : 9 respectively. What is anand's present age in years?

0 Answers  


Replace each letter by a digit. Each letter must be represented by the same digit and no beginning letter of a word can be 0. O N E O N E O N E O N E ------- T E N

1 Answers   Infosys,


16,8,12,30,105,?

3 Answers   NTSE,


There are some houses in a street back to back. And they that house behind 10 were 23. How many houses in the street?

0 Answers   Accenture,


Categories