Question: How many JSP scripting elements are there and what are they? (JSP)
Answer: There are three scripting language elements:
declarations
scriptlets
expressions
Question: In the Servlet 2.4 specification SingleThreadModel has been deprecates, why? (JSP)
Answer: Because it is not practical to have such model. Whether you set isThreadSafe to true or false, you should take care of concurrent client requests to the JSP page by synchronizing access to any shared objects defined at the page level.
Question: what are stored procedures? How is it useful? (JDBC)
Answer: A stored procedure is a set of statements/commands which reside in the database. The stored procedure is precompiled and saves the database the effort of parsing and compiling sql statements everytime a query is run. Each Database has it's own stored procedure language, usually a variant of C with a SQL preproceesor. Newer versions of db's support writing stored procs in Java and Perl too.
Before the advent of 3-tier/n-tier architecture it was pretty common for stored procs to implement the business logic( A lot of systems still do it). The biggest advantage is of course speed. Also certain kind of data manipulations are not achieved in SQL. Stored procs provide a mechanism to do these manipulations. Stored procs are also useful when you want to do Batch updates/exports/houseKeeping kind of stuff on the db. The overhead of a JDBC Connection may be significant in these cases.
Question: What do you understand by private, protected and public?
Answer: These are accessibility modifiers. Private is the most restrictive, while public is the least restrictive. There is no real difference between protected and the default type (also known as package protected) within the context of the same package, however the protected keyword allows visibility to a derived class in a different package.
Question: What is Downcasting ?
Answer: Downcasting is the casting from a general to a more specific type, i.e. casting down the hierarchy
Question: Can a method be overloaded based on different return type but same argument type ?
Answer: No, because the methods can be called without using their return type in which case there is ambiquity for the compiler
Question: What happens to a static var that is defined within a method of a class ?
Answer: Can't do it. You'll get a compilation error
Question: How many static init can you have ?
Answer: As many as you want, but the static initializers and class variable initializers are executed in textual order and may not refer to class variables declared in the class whose declarations appear textually after the use, even though these class variables are in scope.
Question: What is the difference amongst JVM Spec, JVM Implementation, JVM Runtime ?
Answer: The JVM spec is the blueprint for the JVM generated and owned by Sun. The JVM implementation is the actual implementation of the spec by a vendor and the JVM runtime is the actual running instance of a JVM implementation
Question: Describe what happens when an object is created in Java?
Answer: Several things happen in a particular order to ensure the object is constructed properly:
1. Memory is allocated from heap to hold all instance variables and implementation-specific data of the object and its superclasses. Implemenation-specific data includes pointers to class and method data.
2. The instance variables of the objects are initialized to their default values.
3. The constructor for the most derived class is invoked. The first thing a constructor does is call the consctructor for its superclasses. This process continues until the constrcutor for java.lang.Object is called, as java.lang.Object is the base class for all objects in java.
4. Before the body of the constructor is executed, all instance variable initializers and initialization blocks are executed. Then the body of the constructor is executed. Thus, the constructor for the base class completes first and constructor for the most derived class completes last.
Question: What does the "final" keyword mean in front of a variable? A method? A class?
Answer: FINAL for a variable : value is constant
FINAL for a method : cannot be overridden
FINAL for a class : cannot be derived
0 comments:
Post a Comment