1.what is the maximum size of arraylist? 2.what is the drawback of arralist? 2.what is the drawback of JDBC? 4.how many access specifier and how many access modifier in java? 5.what is difference b/w abstract class and interface? 6.which is best b/w abstract class and interface?
1) It depend on heap size of machine and heap size depend on size of RAM. The theoretical maximum number of elements in an ArrayList is 2^31-1.
2)Inserting an element in the middle of the array list and removing an element from the middle of the array list are not efficient since the arraylist has to adjust itself to accomodate the new value. Internally it uses System.arrayCopy method which is a native method to copy the contents from old array to new array. If the array list size is very huge, Insertion and removal operations will slow down the performance of the application.
3)Drawbacks of JDBC :
a) JDBC needs database specifc queries. that means if u r using Oracle then u have to use Oracle queries, due to this reason one can't switch between the databases.
b) We can't retrive each record as object. JDBC retrives it as scalar values only. and we know objects are more faster then scalar values.
c) ResultSet is not serializable JDBC, but RowSet is serializable in jdbc. But it is not supported for all drivers.
d) Exception Handling is one of the main drawback in JDBC. eg :
try { connection.close(); }catch(Exception e) { try { connection.close(); }catch(Exception e) { } } if exception raised closing connection itself , then number of times we need to write try-catch.
e) Each time connection closing is compulsory.
4)Difference between Abstract class and Interface:
a)Interfaces provide a form of multiple inheritance. A class can extend only one other class.
b)Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.
c)A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.
d)Interfaces are slow as it requires extra indirection to to find corresponding method in in the actual class. Abstract classes are fast.
6)In general, prefer interfaces if you don't need to use an abstract class, because they provide more design flexibility.
Ads