Monday, September 27, 2010

Java Interview Questions and Answers - 2

Q 11. Can there be an abstract class with no abstract methodsin it? (Core Java)
Answer
Yes

Q 12. Can an Interface be final? (Core Java)
Answer
No

Q 13. Can an Interface have an inner class? (Core Java)
Answer
Yes.
public interface abc {
static int i=0;
void dd();
class a1 {
a1() {
int j;
System.out.println("in interfia");
};
public static void main(String a1[]) {
System.out.println("in interfia"); } } }

Q 14. Can we define private and protected modifiers for variables in interfaces? (Core Java)
Answer
No
Q 15. What is the query used to display all tables names in SQL Server (Query analyzer)? JDBC)
Answer
select * from information_schema.tables

Q 16. What is Externalizable? (Core Java)
Answer Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in)

Q 17. What modifiers are allowed for methods in an Interface? (Core Java)
Answer
Only public and abstract modifiers are allowed for methods in interfaces.

Q 18. What is a local, member and a class variable? (Core Java)
Answer
Variables declared within a method are "local" variables. Variables declared within the class i.e not within any methods are "member" variables (global variables).

Variables declared within the class i.e not within any methods and are defined as "static" are class variables

Q 19. How many types of JDBC Drivers are present and what are they? (JDBC)
Answer There are 4 types of JDBC Drivers
Type 1: JDBC-ODBC Bridge Driver
Type 2: Native API Partly Java Driver
Type 3: Network protocol Driver
Type 4: JDBC Net pure Java Driver

Q 20. What is the difference between ServletContext and PageContext? (JSP)
Answer
ServletContext: Gives the information about the container
PageContext: Gives the information about the Request

No comments: