Saggezza Java Interview Questions with Answers

Company Name :  Saggezza India pvt ltd

Sent By:  Ashok 

Interview Questions:


1. Tell me about your self?
2. Can i write a abstract class without abstract methods? Ans: Yes, We can write a abstract class without any abstract methods.
3. Can i have a private constructor in an abstract class ?
4. What is the output of the following program
 class Parent {

    void parentMethod() {
        System.out.println("parentMethod....");
    }
}

class Child extends Parent {

    void childMethod() {
        System.out.println("childMethod......");
    }
}

public class TestClass {
    public static void main(String[] args) {
        Parent p = new Parent();
        p.parentMethod();
        Child c1 = p;  // Compile time exception "cannot convert from Parent to Child "
        Child c2 = (Child) p; // Rutime exception "Parent cannot be cast to Child"
        c2.childMethod();
        c2.parentMethod();
    }

}


5.  What is session factory? How will you create a session factory? Ans: SessionFactory is Hibernate s concept of a single datastore and is threadsafe so that many threads can access it concurrently and request for sessions and immutable cache of compiled mappings for a single database. A SessionFactory is usually only built once at startup. SessionFactory should be wrapped in some kind of singleton so that it can be easily accessed in an application code.

SessionFactory sessionFactory = new Configuration().configure().buildSessionfactory();

6.  Explain servelet life cycle? View Answer
7.  Explain second level cache in hibernate?
8.  What is composite primary id in hibernate and how you will write?
9.  Is Hibernate session thread safe? Ans: Session is a light weight and a non-threadsafe object (No, you cannot share it between threads) that represents a single unit-of-work with the database. Sessions are opened by a SessionFactory and then are closed when all work is complete. Session is the primary interface for the persistence service. A session obtains a database connection lazily (i.e. only when required).
10. What is request dispatcher ? View Answer



Kindly Send your attended interview Questions and Answers to faqs@javastuff.com

Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email