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


Please Help Members By Posting Answers For Below Questions

The price of raw materials has gone up by 15%, labour cost has also increased from 25% of the cost of raw material to 30% of the cost of raw material. By how much percentage should there be a reduction in the usage of raw materials so as to keep the cost same

1124


In Madras, temperature at noon varies according to -t^2/2 + 8t + 3, where t is elapsed time. Find how much temperature more or less in 4pm to 9pm.

1022


Denominator is 4 greater than numerator if 10 is added to Denominator,the fraction becomes 1/8.what is the fraction.

802


10 : 4 seconds :: ? : 6 minutes

1040


Find the least value of 3x + 4y if x2y3 = 6.

1002






Find the nth number in the series is 1, -3, 5, -7.___

881


There are 9 balls of equal size and same weight (they look similar) except 1. How may weighs required to find the dissimilar ball using a weighing balance?

822


Which is the biggest perfect square amongst the following 15129, 12348, 23716, 20736

1658


A hotel has 10 storeys. Which floor is above the floor below the floor, below the floor above the floor, below the floor above the fifth.

1269


If A is travelling at 72 km per hour on a highway. B is travelling at a speed of 25 meters per second on a highway. What is the difference in their speeds in m/sec.

780


Fill the empty slots. Three FOOTBALL teams are there. Given below the list of maches. played won lost draw Goals for Goals against A 2 2 *0 *0 *7 1 B 2 *0 *1 1 2 4 C 2 *0 *1 *1 3 7 the slots with stars are answers.

880


A person spending out 1/3 for cloths , 1/5 of the remaining for food and 1/4 of the remaining for travellers is left with Rs 100/- . How he had in the beginning ?

901


Grass in lawn grows equally thick and in a uniform rate. It takes 24 days for 70 cows and 60 for 30 cows . How many cows can eat away the same in 96 days.?

842


Hello!!I have appllied for the post of Jr.Executive(ATC).My educational qualification is B.Tech(IT).I ould like to know if the questions in technical section will be based on IT alone or else also from other subjects also like electrical/electronics/civil/tele communication.I will be grateful for a relevant answer.thank you in advance

2082


X2 – (A-3)X +(A+3) = 0 for what value of A the sum of square of roots will be least ?

888