Saturday, December 12, 2009

Java Fundamental-III


1. When should the method invokeLater()be used?
This method is used to ensure that Swing components are updated through the event-dispatching thread.


2. How can a subclass call a method or a constructor defined in a superclass?
Use the following syntax: super.myMethod(); To call a constructor of the superclass, just write super(); in the first line of the subclass’s constructor.


3. What’s the difference between a queue and a stack?
Stacks works by last-in-first-out rule (LIFO), while queues use the FIFO rule.


4. You can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces?
Sometimes. But your class may be a descendent of another class and in this case the interface is your only option.


5. What comes to mind when you hear about a young generation in Java?
Garbage collection.


6. What comes to mind when someone mentions a shallow copy in Java?
Object cloning.


7. If you’re overriding the method equals() of an object, which other method you might also consider?
hashCode()


8. You are planning to do an indexed search in a list of objects. Which of the two Java collections should you use: ArrayList or LinkedList?
ArrayList


9. How would you make a copy of an entire Java object with its state?
Have this class implement Cloneable interface and call its method clone().




10. How can you minimize the need of garbage collection and make the memory use more effective?
Use object pooling and weak object references.


11. There are two classes: A and B. The class B need to inform a class A when some important event has happened. What Java technique would you use to implement it?
If these classes are threads I’d consider notify() or notifyAll(). For regular classes you can use the Observer interface.


12. What access level do you need to specify in the class declaration to ensure that only classes from the same directory can access it?
You do not need to specify any access level, and Java will use a default package access level


13. What are the contents of web module?
Answer: A web module may contain:
a) JSP files
b) Java classes
c) gif and html files and
d) web component deployment descriptor


14. Differentiate between .ear, .jar and .war files.
Answer: These files are simply zipped file using java jar tool. These files are created for different purposes. Here is the description of these files:
.jar files: These files are with the .jar extenstion. The .jar files contains the libraries, resources and accessories files like property files.
.war files: These files are with the .war extension. The war file contains the web application that can be deployed on the any servlet/jsp container. The .war file contains jsp, html, javascript and other files for necessary for the development of web applications.
.ear files: The .ear file contains the EJB modules of the application.


15. What is the difference between Session Bean and Entity Bean?
Answer:
Session Bean: Session is one of the EJBs and it represents a single client inside the Application Server. Stateless session is easy to develop and its efficient. As compare to entity beans session beans require few server resources.


A session bean is similar to an interactive session and is not shared; it can have only one client, in the same way that an interactive session can have only one user. A session bean is not persistent and it is destroyed once the session terminates.


Entity Bean: An entity bean represents persistent global data from the database. Entity beans data are stored into database.


16. Why J2EE is suitable for the development distributed multi-tiered enterprise applications?
Answer: The J2EE platform consists of multi-tiered distributed application model. J2EE applications allows the developers to design and implement the business logic into components according to business requirement. J2EE architecture allows the development of multi-tired applications and the developed applications can be installed on different machines depending on the tier in the multi-tiered J2EE environment . The J2EE application parts are:


a) Client-tier components run on the client machine.
b) Web-tier components run on the J2EE server.
c) Business-tier components run on the J2EE server and the
d) Enterprise information system (EIS)-tier software runs on the EIS servers


17. Why do understand by a container?
Answer: Normally, thin-client multi-tiered applications are hard to write because they involve many lines of intricate code to handle transaction and state management, multithreading, resource pooling, and other complex low-level details. The component-based and platform-independent J2EE architecture makes J2EE applications easy to write because business logic is organized into reusable components. In addition, the J2EE server provides underlying services in the form of a container for every component type. Because you do not have to develop these services yourself, you are free to concentrate on solving the business problem at hand (Source: http://java.sun.com/j2ee/1.3/docs/tutorial/doc/Overview4.html ).


In short containers are the interface between a component and the low-level platform specific functionality that supports the component. The application like Web, enterprise bean, or application client component must be assembled and deployed on the J2EE container before executing.


18. What are the services provided by a container?
Answer: The services provided by container are as follows:
a) Transaction management for the bean
b) Security for the bean
c) Persistence of the bean
d) Remote access to the bean
e) Lifecycle management of the bean
f) Database-connection pooling
g) Instance pooling for the bean

Sunday, November 29, 2009

Database System-I

1.What is foreign Key? What is its purpose?
A non key attribute, whose value are derived from the primary key of some other table, is known as foreign key in the current table.The table in which this non-key attribute i.e. foreign key attribute exists, is called a foreign table.

2.Define the terms  Tuple and  Attribute
Tuples: The rows of tables (relations) are generally referred to as tuples. Attribute: The columns of tables are generally referred to as attribute.

3.What do you understand by the terms Cardinality and Degree of the table?
Degree: The number of attributes in a relation determines the degree of a relation. A relation having 3 attributes is said to be a relation of degree 3.
Cardinality: The number of rows in a relation is known as Cardinality.

4.What is the main function of DBA.
The DBA must be a manager, more than a technician-seeking to meet the needs of people who use the data. Since many user may share the same data resource, the DBA must be prepared to meet the need and objective.

5.Write a query on the customers table whose output will exclude all customers with a rating <=100, unless they are located in Shimla.
SELECT *  FROM customers  WHERE rating >100 OR city =’Shimla’ ;

6.Write a query that selects all orders except those zeros or NULLs in  the amount field.
SELECT * FROM Orders  WHERE amt < >0  AND (amt IS NOT NULL) ;

7.Write a query that lists customers in descending order of rating. Output the rating field first, followed by the customer’s name and number.
SELECT rating, cust-name, cust-num FROM customers ORDER BY rating DESC;

8.Write a command that puts the following values, in their given order, into the salesman table: cust-name-Manisha, city-Manali, comm.- NULL, cust-num-1901.
INSERT INTO salesman (city, cust-name, comm.,cust-num)VALUES(‘Manisha’,NULL,1901) ;

9.What are DDL and DML?
The DDL provides statements for the creation and deletion of tables and indexes.
The DML provides statements to enter, update, delete data and perform complex queries on these tables.

10.What is the difference between Where and Having Clause?
The HAVING clause places the condition on group but WHERE clause places the condition on individual rows

11.What do you understand by constraints?
Constraints are used to enforce rules at table level when ever row is inserted, updated/deleted from table.
Constraints can be defined to one of the Two level.
Column Level: Reference to a single column. can be defined any type of integrity.
Table Level: References one or more columns and is defined separately from definition of the columns in the table.

12.Write some features of SQL?
Recovery ad Concurrency:- Concurrency is concerned with the manner in which multiple user operate upon the Database.
Security: The Security can be maintained by view mechanism.
Integrity Constraints-> Integrity constraints are enforced by the system.

13.Write various database objects available in SQL?
Table: A Table is used to store Data
View: A view is the temporary table created using Original table.
Sequence:   Sequences are used to generate Primary key value.
Index:  They are used to improve queries.
Synonym: They give alternative names to objects.     

14.Write the rules to name an objects?
The maximum length must be 30 character long.
The Object name  should not contain quotation mark.
The name must start with letter.
The use of $ and # is discouraged in the object name.
A name must not be a reserved name.

15.What are group Functions?
The aggregate functions are group functions. They return result based on groups of rows. The group functions are
AVG(), COUNT(), MAX(),  MIN(), SUM()

16.What are  column alias?
In many  cases heading table may not be descriptive and hence it difficult to understand. In  such case we use columns alias It will change column heading with column alias.

Search Aptipedia