Tuesday, August 31, 2010

Interview questions PM


1) How to call functions from oracle?

2) The difference between drop and truncate table.

2) What is the difference between function and stored procedure?
1. Function is mainly used in the case where it must return a value. Where as a procedure may or may not return a value or may return more than one value using the OUT parameter.
Â
2. Function can be called from SQL statements where as procedure can not be called from the sql statements

3. Functions are normally used for computations where as procedures are normally used for executingbusiness logic.

4. You can have DML (insert,update, delete) statements in a function. But, you cannot call such a function in a SQL query.

5. Function returns 1 value only. Procedure can return multiple values (max 1024).

6.Stored Procedure: supports deferred name resolution. Example while writing a stored procedure that uses table named tabl1 and tabl2 etc..but actually not exists in database is allowed only in during creation but runtime throws error Function wont support deferred name resolution.

7.Stored procedure returns always integer value by default zero. where as function return type could be scalar or table or table values

8. Stored procedure is precompiled execution plan where as functions are not.
Â
9.A procedure may modify an object where a function can only return a value The RETURN statement immediately completes the execution of a subprogram and returns control to the caller.

2) What are different artifacts required at different stages of project management.

3) What are different statistical reports do you generate

4) CPM of the project management.

4.1) Difference between enumeration and iterator
Enumeration does not have remove method but iteration has.......

5) Definition of a milestone.
A significant event in the project, usually completion of a major deliverable.

6) Distribution of effort in project management.

7) Defect density.
Defect density refers to the ratio of number of defects to program size, typically measured in lines of code (LOC) or function points (FP)

8) Class loading have a delegation where if the child is not able to find, it will delegate to parent to find the class.


Static variables are stored in the heap area called perm generation.


By default, classes in Java do not support cloning; the default implementation of the clone() method throws a CloneNotSupportedException. You should override implementation of the clone() method. Remember that you must make it public and, inside the method, your first action must be super.clone(). Classes that want to allow cloning must implement the marker interface Cloneable. Since the default implementation of Object.clone only performs a shallow copy, classes must also override clone to provide a custom implementation when a deep copy is desired. Basically, if you want to make objects of your class publicly cloneable, you need code like this:



The only requirement on the constructor for a class that implements Serializable is that the first non-serializable superclass in its inheritence hierarchy must have a no-argument constructor.

he virtual machine incorporated a number of different garbage collection algorithms that are combined using generational collection.

When the young generation fills up it causes a minor collection.Minor collections can be optimized assuming a high infant mortality rate.

Some surviving objects are moved to atenured generation. When the tenured generation needs to be collected there is a major collectionthat is often much slower because it involves all live objects.

If the garbage collector has become a bottleneck, you may wish to customize the generation sizes. Check the verbose garbage collector output, and then explore the sensitivity of your individual performance metric to the garbage collector parameters.

The young generation consists of eden plus two survivor spaces . Objects are initially allocated in eden. One survivor space is empty at any time, and serves as a destination of the next, copying collection of any live objects in eden and the other survivor space. Objects are copied between survivor spaces in this way until they are old enough to be tenured, or copied to the tenuredgeneration.

Thepermanent generation is special because it holds data needed by the virtual machine to describe objects that do not have an equivalence at the Java language level. For example objects describing classes and methods are stored in the permanent generation.

-verbose:gc

The bridge pattern is a design pattern used in software engineering which is meant to "decouple an abstraction from its implementation so that the two can vary independently" [1]. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.


the adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface

use case generalization is reverse arrow.


The composite pattern describes that a group of objects are to be treated in the same way as a single instance of an object.

In object-oriented programming, the decorator pattern is a design pattern that allows new/additional behaviour to be added to an existing object dynamically.

A facade is an object that provides a simplified interface to a larger body of code, such as a class library. A facade can:

  • make a software library easier to use and understand and test, since the facade has convenient methods for common tasks;
  • make code that uses the library more readable, for the same reason;
  • reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system;
  • wrap a poorly-designed collection of APIs with a single well-designed API (as per task needs).
A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate.

The memento pattern is a software design pattern that provides the ability to restore an object to its previous state (undo via rollback).


  • Atomicity—all changes that a transaction makes to a database are made as one unit; otherwise, all changes are rolled back.
  • Consistency—a successful transaction transforms a database from a previous valid state to a new valid state.
  • Isolation—changes that a transaction makes to a database are not visible to other operations until the transaction completes its work.
  • Durability—changes that a transaction makes to a database survive future system or media failures.

For XA drivers, the system automatically selects the Two-Phase Commit protocol for global transaction processing.

Emulate Two-Phase Commit: With this option, the transaction branch in which the connection is used always returns success for the prepare phase of the transaction. It offers performance benefits, but also has risks to data in some failure conditions. Select this option only if your application can tolerate heuristic conditions.


  1. Import the following classes:
  2. import javax.transaction.UserTransaction;
    import java.sql.*;
    import javax.naming.*;
    import java.util.*;
    import weblogic.jndi.*;
  3. Establish the transaction by using the UserTransaction class. You can look up this class on the JNDI tree. The UserTransaction class controls the transaction on the current execute thread. Note that this class does not represent the transaction itself. The actual context for the transaction is associated with the current execute thread.
  4. Context ctx = null;
    Hashtable env = new Hashtable();

    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");

    // Parameters for the WebLogic Server.
    // Substitute the correct hostname, port number
    // user name, and password for your environment:
    env.put(Context.PROVIDER_URL, "t3://localhost:7001");
    env.put(Context.SECURITY_PRINCIPAL, “Fred”);
    env.put(Context.SECURITY_CREDENTIALS, “secret”);

    ctx = new InitialContext(env);

    UserTransaction tx = (UserTransaction)
    ctx.lookup("javax.transaction.UserTransaction");
  5. Start a transaction on the current thread:
  6. // Start the global transaction before getting a connection
    tx.begin();
  7. Load the JTS driver:
  8. Driver myDriver = (Driver)
    Class.forName("weblogic.jdbc.jts.Driver").newInstance();
  9. Get a connection from the data source:
  10. Properties props = new Properties();
    props.put("connectionPoolID", "myDataSource");

    conn = myDriver.connect("jdbc:weblogic:jts", props);
  11. Execute your database operations. These operations may be made by any service that uses a database connection, including EJB, JMS, and standard JDBC statements. These operations must use the JTS driver to access the same data source as the transaction begun in step 3 in order to participate in that transaction.
  12. If the additional database operations using the JTS driver use a different data source than the one specified in step 5, an exception will be thrown when you try to commit or roll back the transaction.

  13. Close your connection objects. Note that closing the connections does not commit the transaction nor return the connection to the pool:
  14. conn.close();
  15. Complete the transaction by either committing the transaction or rolling it back. In the case of a commit, the JTS driver commits all the transactions on all connection objects in the current thread and returns the connection to the pool.
  16. tx.commit();

    // or:

    tx.rollback();


    Resultset wasnull will give the option whether the value is null or not


    UserTransaction tx = (UserTransaction)
    ctx.lookup("javax.transaction.UserTransaction");
    tx.begin();


    PreparedStatement is not compiling query every time.
    PreparedStatement is better for CLOB and BLOB object.
    Example:


    transaction attribute may have one of the following values:

    • Required
    • RequiresNew
    • Mandatory
    • NotSupported
    • Supports
    • Never

    Required

    If the client is running within a transaction and invokes the enterprise bean's method, the method executes within the client's transaction. If the client is not associated with a transaction, the container starts a new transaction before running the method.

    The Required attribute will work for most transactions. Therefore, you may want to use it as a default, at least in the early phases of development. Because transaction attributes are declarative, you can easily change them at a later time.

    RequiresNew

    If the client is running within a transaction and invokes the enterprise bean's method, the container takes the following steps:

    1. Suspends the client's transaction
    2. Starts a new transaction
    3. Delegates the call to the method
    4. Resumes the client's transaction after the method completes

    If the client is not associated with a transaction, the container starts a new transaction before running the method.

    You should use the RequiresNew attribute when you want to ensure that the method always runs within a new transaction.

    Mandatory

    If the client is running within a transaction and invokes the enterprise bean's method, the method executes within the client's transaction. If the client is not associated with a transaction, the container throws theTransactionRequiredException.

    Use the Mandatory attribute if the enterprise bean's method must use the transaction of the client.

    NotSupported

    If the client is running within a transaction and invokes the enterprise bean's method, the container suspends the client's transaction before invoking the method. After the method has completed, the container resumes the client's transaction.

    If the client is not associated with a transaction, the container does not start a new transaction before running the method.

    Use the NotSupported attribute for methods that don't need transactions. Because transactions involve overhead, this attribute may improve performance.

    Supports

    If the client is running within a transaction and invokes the enterprise bean's method, the method executes within the client's transaction. If the client is not associated with a transaction, the container does not start a new transaction before running the method.

    Because the transactional behavior of the method may vary, you should use the Supports attribute with caution.

    Never

    If the client is running within a transaction and invokes the enterprise bean's method, the container throws a RemoteException. If the client is not associated with a transaction, the container does not start a new transaction before running the method.


    setup() for setting up

    teardown() for releasing the resources.



    MVC1 is request goes to JSP which works as controller.

    MVC2 the request goes to servlet which works as controller.



    Different modules of spring are

    • The core container provides the essential functionality of the Spring framework. A primary component of the core container is the BeanFactory, an implementation of the Factory pattern. The BeanFactory applies the Inversion of Control (IOC) pattern to separate an application's configuration and dependency specification from the actual application code.
    • The Spring context is a configuration file that provides context information to the Spring framework. The Spring context includes enterprise services such as JNDI, EJB, e-mail, internalization, validation, and scheduling functionality.
    • The Spring AOP module integrates aspect-oriented programming functionality directly into the Spring framework, through its configuration management feature. As a result you can easily AOP-enable any object managed by the Spring framework. The Spring AOP module provides transaction management services for objects in any Spring-based application. With Spring AOP you can incorporate declarative transaction management into your applications without relying on EJB components.
    • The Spring JDBC DAO abstraction layer offers a meaningful exception hierarchy for managing the exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the amount of exception code you need to write, such as opening and closing connections. Spring DAO's JDBC-oriented exceptions comply to its generic DAO exception hierarchy.
    • The Spring framework plugs into several ORM frameworks to provide its Object Relational tool, including JDO, Hibernate, and iBatis SQL Maps. All of these comply to Spring's generic transaction and DAO exception hierarchies.
    • The Web context module builds on top of the application context module, providing contexts for Web-based applications. As a result, the Spring framework supports integration with Jakarta Struts. The Web module also eases the tasks of handling multi-part requests and binding request parameters to domain objects.
    • The Model-View-Controller (MVC) framework is a full-featured MVC implementation for building Web applications. The MVC framework is highly configurable via strategy interfaces and accommodates numerous view technologies including JSP, Velocity, Tiles, iText, and POI.
      • Setter-based DI is realized by calling setter methods on your beans after invoking a no-argument constructor or no-argument static factory method to instantiate your bean.

      • Constructor-based DI is realized by invoking a constructor with a number of arguments, each representing a collaborator.

      What is Bean Factory ?

      A BeanFactory is like a factory class that contains a collection of beans. The BeanFactory holds Bean Definitions of multiple beans within itself and then instantiates the bean whenever asked for by clients.

      • BeanFactory is able to create associations between collaborating objects as they are instantiated. This removes the burden of configuration from bean itself and the beans client.
      • BeanFactory also takes part in the life cycle of a bean, making calls to custom initialization and destruction methods.

      What is the difference between Bean Factory and Application Context ?

      On the surface, an application context is same as a bean factory. But application context offers much more..

      • Application contexts provide a means for resolving text messages, including support for i18n of those messages.
      • Application contexts provide a generic way to load file resources, such as images.
      • Application contexts can publish events to beans that are registered as listeners.
      • Certain operations on the container or beans in the container, which have to be handled in a programmatic fashion with a bean factory, can be handled declaratively in an application context.
      • ResourceLoader support: Spring’s Resource interface us a flexible generic abstraction for handling low-level resources. An application context itself is a ResourceLoader, Hence provides an application with access to deployment-specific Resource instances.
      • MessageSource support: The application context implements MessageSource, an interface used to obtain localized messages, with the actual implementation being pluggable

      . How is a typical spring implementation look like ?

      For a typical Spring Application we need the following files:

      • An interface that defines the functions.

      • An Implementation that contains properties, its setter and getter methods, functions etc.,

      • Spring AOP (Aspect Oriented Programming)

      • A XML file called Spring configuration file.

      • Client program that uses the function.



        14. What is the typical Bean life cycle in Spring Bean Factory Container ?

        Bean life cycle in Spring Bean Factory Container is as follows:

        • The spring container finds the bean’s definition from the XML file and instantiates the bean.

        • Using the dependency injection, spring populates all of the properties as specified in the bean definition

        • If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID.

        • If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of itself.

        • If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization() methods will be called.

        • If an init-method is specified for the bean, it will be called.

        • Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called.

          14. What is the typical Bean life cycle in Spring Bean Factory Container ?

          Bean life cycle in Spring Bean Factory Container is as follows:

          • The spring container finds the bean’s definition from the XML file and instantiates the bean.

          • Using the dependency injection, spring populates all of the properties as specified in the bean definition

          • If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID.

          • If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of itself.

          • If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization() methods will be called.

          • If an init-method is specified for the bean, it will be called.

          • Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called.