Correct Answer: Array is collection of same data type Array size is fixed, It cannot be expanded But ArrayList is a growable collection of objectsArrayList is a part of Collections Framework and can work with only objects
Correct Answer: An abstract class is an incomplete class An abstract class is defined with the keyword abstract We cannot create an object of the abstract class because it is not complete It sets a behavioral protocol for all its child classes
4. What is the difference between a constructor and a method?
Correct Answer: A constructor is a member function of a class that is used to create objects of that class It has the same name as the class itself, has no return type, and is invoked using the new operator We cannot invoke a constructor directly A method is an ordinary member function of a class It has its own name, a return type (which may be void), and is invoked using the dot operator
5. What are the steps required to execute a query in JDBC?
Correct Answer: First we need to create an instance of a JDBC driver or load JDBC drivers, then we need to register this driver with DriverManager class Then we can open a connection By using this connection , we can create a statement object and this object will help us to execute the query
Correct Answer: Yes, we can In order to compile a java program, we don't require any main method But to execute a java program we must have a main in it (unless it is an applet or servlet) Because main is the starting point of a java program
10. What are the restrictions when overriding a method ?
Correct Answer: Overridden methods must have the same name, argument list, and return type (ie, they must have the exact signature of the method we are going to override, including return type) The overriding method cannot be less visible than the method it overrides( ie, a public method cannot be override to private) The overriding method may not throw any exceptions that may not be thrown by the overridden method