Saturday, May 2, 2009

Concepts About Agile Methodology, CVS, SEAM, Spring, IBM WebSphere

Agile Methodology

Estimation of the project…
Estimation of that week work
Confirmation of the estimation with project manager…
Starts working on that week task…
Every morning before starting the work full team has to get together and tell about our self that
1. What we did yesterday.
2. What we are going to do today.
3. Any backlogs and problems while working like admin or system and application bugs…

Every Friday of that week has code review and if any changes are made it reflects for next week.
Achievements in the work of that week. If backlogs we discuss the problem and solution will transfer with in the team…
Discussion regarding whether we reached the goals for that week.
Appreciation part includes in the meeting on Friday…(ex: if u done with ur work of that week and so more work of the next week also then manager will appreciate the team member in front of full team)

Over all by the agile development we use to resolve our problems with time line …
Team communication will have more, so that we can transfer our knowledge if any person stuck on any issue (regarding the task issues)
Some of the principles behind the Agile Manifesto are:
Customer satisfaction by rapid, continuous delivery of useful software
Working software is delivered frequently (weeks rather than months)
Working software is the principal measure of progress
Even late changes in requirements are welcomed (this does not mean code & run. Instead removing an existing feature or moving a deadline forward to accommodate late/unplanned feature requests)
Close, daily cooperation between business people and developers
Face-to-face conversation is the best form of communication (Co-location)
Projects are built around motivated individuals, who should be trusted

Continuous attention to technical excellence and good design
Simplicity
Self-organizing teams
Regular adaptation to changing circumstances

CVS(Concurrent Versioning System)

CVS is a utility to help manage a group of users that are all editing the same group of files at the same time. A CVS repository is simply the collection of files under CVS management. Typically, CVS is used to manage source code when there are multiple developers on a project. In this case, "repository" typically means the most recent versions of the source code used in the project.

CVS is a version control system, an important component of Source Configuration Management (SCM). Using it, you can record the history of sources files, and documents. It fills a similar role to the free software RCS, PRCS, and Aegis packages.

CVS is a production quality system in wide use around the world, including many free software projects.
While CVS stores individual file history in the same format as RCS, it offers the following significant advantages over RCS:
It can run scripts which you can supply to log CVS operations or enforce site-specific polices.

Client/server CVS enables developers scattered by geography or slow modems to function as a single team. The version history is stored on a single central server and the client machines have a copy of all the files that the developers are working on. Therefore, the network between the client and the server must be up to perform CVS operations (such as checking’s or updates) but need not be up to edit or manipulate the current versions of the files. Clients can perform all the same operations which are available locally.

In cases where several developers or teams want to each maintain their own version of the files, because of geography and/or policy, CVS's vendor branches can import a version from another team (even if they don't use CVS), and then CVS can merge the changes from the vendor branch with the latest files if that is what is desired.
Unreserved checkouts, allowing more than one developer to work on the same files at the same time.

CVS provides a flexible modules database that provides a symbolic mapping of names to components of a larger software distribution. It applies names to collections of directories and files. A single command can manipulate the entire collection.
CVS servers run on most unix variants, and clients for Windows NT/95, OS/2 and VMS are also available. CVS will also operate in what is sometimes called server mode against local repositories on Windows 95/NT.

Java Development within Eclipse


Even before you start writing Java code, you need to familiarize yourself with the Eclipse Workbench and its various elements. This is because the Java Development Tools (JDT), as well as many other Eclipse-based development tools (such as PDE), build upon this framework to deliver their own functionality. As you already know, Eclipse is a component-based platform (components in Eclipse-speak are called plug-ins, or bundles) and Eclipse-based applications (such as the Eclipse SDK) are highly modular. Eclipse SDK itself consists of a mixture of plug-ins, which together make it what it is; other Eclipse-based applications may share some of those plug-ins, but usually bring along their own set of plug-ins that differentiate them.
At a high level, you can think of the Workbench as a window (or a set of windows) around which all of the visual elements of an application are organized. It is the window you'll see when you launch your Eclipse SDK. Not all Eclipse-based applications must necessarily use the Workbench; in fact, it is possible to create "headless" applications that are completely driven from the command-line (or through other, non-visual means). However, complex rich-client applications, such as IDEs, are typically based on the Workbench. (In fact, what you'll see in an IDE is typically the IDE Workbench, a special flavor of the Generic Workbench provided by Eclipse.)

SEAM


Seam is a powerful open source development platform for building rich Internet applications in Java. Seam integrates technologies such as Asynchronous JavaScript and XML (AJAX), JavaServer Faces (JSF), Java Persistence (JPA), Enterprise Java Beans (EJB 3.0) and Business Process Management (BPM) into a unified full-stack solution, complete with sophisticated tooling.
Seam has been designed from the ground up to eliminate complexity at both architecture and API levels. It enables developers to assemble complex web applications using simple annotated Java classes, a rich set of UI components, and very little XML. Seam's unique support for conversations and declarative state management can introduce a more sophisticated user experience while at the same time eliminating common bugs found in traditional web applications.

Spring


Spring is not necessarily one more framework dependency for your project. Spring is potentially a one-stop shop, addressing most infrastructure concerns of typical applications. It also goes places other frameworks don't.
An open source project since February 2003, Spring has a long heritage. The open source project started from infrastructure code published with my book, Expert One-on-One J2EE Design and Development, in late 2002. Expert One-on-One J2EE laid out the basic architectural thinking behind Spring. However, the architectural concepts go back to early 2000, and reflect my experience in developing infrastructure for a series of successful commercial projects.

Since January 2003, Spring has been hosted on SourceForge. There are now 20 developers, with the leading contributors devoted full-time to Spring development and support. The flourishing open source community has helped it evolve into far more than could have been achieved by any individual.

Architectural benefits of Spring:
Before we get down to specifics, let's look at some of the benefits Spring can bring to a project:

Spring can effectively organize your middle tier objects, whether or not you choose to use EJB. Spring takes care of plumbing that would be left up to you if you use only Struts or other frameworks geared to particular J2EE APIs. And while it is perhaps most valuable in the middle tier, Spring's configuration management services can be used in any architectural layer, in whatever runtime environment.
Spring can eliminate the proliferation of Singletons seen on many projects. In my experience, this is a major problem, reducing testability and object orientation.
Spring can eliminate the need to use a variety of custom properties file formats, by handling configuration in a consistent way throughout applications and projects. Ever wondered what magic property keys or system properties a particular class looks for, and had to read the Javadoc or even source code? With Spring you simply look at the class's JavaBean properties or constructor arguments. The use of Inversion of Control and Dependency Injection (discussed below) helps achieve this simplification.
Spring can facilitate good programming practice by reducing the cost of programming to interfaces, rather than classes, almost to zero.

Spring is designed so that applications built with it depend on as few of its APIs as possible. Most business objects in Spring applications have no dependency on Spring.
Applications built using Spring are very easy to unit test.
Spring can make the use of EJB an implementation choice, rather than the determinant of application architecture. You can choose to implement business interfaces as POJOs or local EJBs without affecting calling code.
Spring helps you solve many problems without using EJB. Spring can provide an alternative to EJB that's appropriate for many applications. For example, Spring can use AOP to deliver declarative transaction management without using an EJB container; even without a JTA implementation, if you only need to work with a single database.

Spring provides a consistent framework for data access, whether using JDBC or an O/R mapping product such as TopLink, Hibernate or a JDO implementation.
Spring provides a consistent, simple programming model in many areas, making it an ideal architectural "glue." You can see this consistency in the Spring approach to JDBC, JMS, JavaMail, JNDI and many other important APIs.

IBM's WebSphere Application Server

The WebSphere Application Server drives business agility by providing millions of developers and IT Architects with an innovative, performance-based foundation to build, reuse, run, integrate and manage Service Oriented Architecture (SOA) applications and services. From business critical and key enterprise-wide applications to the smallest departmental level applications, WebSphere Application Server offers the highest levels of reliability, availability, security and scalability.
Only WebSphere Application Server has the three foundational attributes to enable robust and agile business applications: Simplified Development, High Performance and Intelligent Management.

Simplified Development Increase developer productivity with a proven, standards-based platform. WebSphere Application Server V7 offers enhanced support for standards, emerging technology and a choice of development frameworks that simplifies programming models to increase developer productivity. Integral tooling makes the most of existing technology skills for rapid time-to-value.
· Java EE 5 certification, EJB 3.0 support and Java Persistence API (JPA) and Java Development Kit (JDK) 6.0, deliver simplified programming models for building reusable persistent object
· Web services support, including JAX-WS, SOAP 1.2, MTOM, XOP, WS-ReliableMessaging, WS-Trust, WS-SecureConversation, WS-Policy, and Kerberos Token Profile, simplifies interoperability in mixed environments
· Web 2.0 support (via Feature Pack for Web 2.0) extends Service Oriented Architecture (SOA) by connecting external Web services, internal SOA services, and Java Platform Enterprise Edition (JEE) objects into highly interactive Web application interfaces
· Session Initiation Protocol (SIP) servlets simplify development with standardized support for interactive user sessions involving real-time multimedia elements such as voice, video, instant messaging and online games
· Spring has certification for use with WebSphere Application Server to enable module-based programming
· Single-step installation and configuration, wizards and default configurations, and easy- to-navigate documentation that includes extensive use of sample code help ensure fast and smooth start-up
· IBM Rational® Application Developer for WebSphere V7.5 is available and fully exploits capabilities within WebSphere Application Server V7, accelerating delivery of higher quality, mission-critical applications
· WebSphere Application Server Feature Packs simplify the adoption of new standards such Services Component Architecture (SCA), and improve consumability by enabling users to selectively take advantage of new standards and features while maintaining a more stable internal release cycle.

Monday, March 9, 2009

A bit about Garbage Collection in Java


This assertion has yet to be proven to my satisfaction. However, I've begun to see that many of my doubts about speed come from early implementations that were not particularly efficient so there was no model at which to point to explain how Java could be fast.

Part of the way I've thought about speed has come from being cloistered with the C++ model. C++ is very focused on everything happening statically, at compile time, so that the run-time image of the program is small and fast. C++ is also based directly on the C model, primarily for backwards compatibility, but sometimes simply because it worked a particular way in C so it was the easiest approach in C++. One of the most important cases is the way memory is managed in C and C++, and this has to do with one of my more fundamental assertions about why Java must be slow: in Java, all objects must be created on the heap.

In C++, creating objects on the stack is fast because when you enter a particular scope the stack pointer is moved down once to allocate storage for all the stack-based objects created in that scope, and when you leave the scope (after all the local destructors have been called) the stack pointer is moved up once. However, creating heap objects in C++ is typically much slower because it's based on the C concept of a heap as a big pool of memory that (and this is essential) must be recycled. When you call delete in C++ the released memory leaves a hole in the heap, so when you call new, the storage allocation mechanism must go seeking to try to fit the storage for your object into any existing holes in the heap or else you'll rapidly run out of heap storage. Searching for available pieces of memory is the reason that allocating heap storage has such a performance impact in C++, so it's far faster to create stack-based objects.

Again, because so much of C++ is based on doing everything at compile-time, this makes sense. But in Java there are certain places where things happen more dynamically and it changes the model. When it comes to creating objects, it turns out that the garbage collector can have a significant impact on increasing the speed of object creation. This might sound a bit odd at first - that storage release affects storage allocation - but it's the way some JVMs work and it means that allocating storage for heap objects in Java can be nearly as fast as creating storage on the stack in C++.

You can think of the C++ heap (and a slow implementation of a Java heap) as a yard where each object stakes out its own piece of turf. This real estate can become abandoned sometime later and must be reused. In some JVMs, the Java heap is quite different; it's more like a conveyor belt that moves forward every time you allocate a new object. This means that object storage allocation is remarkably rapid. The "heap pointer" is simply moved forward into virgin territory, so it's effectively the same as C++'s stack allocation. (Of course, there's a little extra overhead for bookkeeping but it's nothing like searching for storage.)

Now you might observe that the heap isn't in fact a conveyor belt, and if you treat it that way you'll eventually start paging memory a lot (which is a big performance hit) and later run out. The trick is that the garbage collector steps in and while it collects the garbage it compacts all the objects in the heap so that you've effectively moved the "heap pointer" closer to the beginning of the conveyor belt and further away from a page fault. The garbage collector rearranges things and makes it possible for the high-speed, infinite-free-heap model to be used while allocating storage.

To understand how this works, you need to get a little better idea of the way the different garbage collector (GC) schemes work. A simple but slow GC technique is reference counting. This means that each object contains a reference counter, and every time a handle is attached to an object the reference count is increased. Every time a handle goes out of scope or is set to null, the reference count is decreased. Thus, managing reference counts is a small but constant overhead that happens throughout the lifetime of your program. The garbage collector moves through the entire list of objects and when it finds one with a reference count of zero it releases that storage. The one drawback is that if objects circularly refer to each other they can have non-zero reference counts while still being garbage. Locating such self-referential groups requires significant extra work for the garbage collector. Reference counting is commonly used to explain one kind of garbage collection but it doesn't seem to be used in any JVM implementations.

In faster schemes, garbage collection is not based on reference counting. Instead, it is based on the idea that any non-dead object must ultimately be traceable back to a handle that lives either on the stack or in static storage. The chain might go through several layers of objects. Thus, if you start in the stack and the static storage area and walk through all the handles you'll find all the live objects. For each handle that you find, you must trace into the object that it points to and then follow all the handles in that object, tracing into the objects they point to, etc., until you've moved through the entire web that originated with the handle on the stack or in static storage. Each object that you move through must still be alive. Note that there is no problem with detached self-referential groups - these are simply not found, and are therefore automatically garbage.

In the approach described here, the JVM uses an adaptive garbage-collection scheme, and what it does with the live objects that it locates depends on the variant currently being used. One of these variants is stop-and-copy. This means that, for reasons that will become apparent, the program is first stopped (this is not a background collection scheme). Then, each live object that is found is copied from one heap to another, leaving behind all the garbage. In addition, as the objects are copied into the new heap they are packed end-to-end, thus compacting the new heap (and allowing new storage to simply be reeled off the end as previously described).

Of course, when an object is moved from one place to another, all handles that point at (reference) that object must be changed. The handle that comes from tracing to the object from the heap or the static storage area can be changed right away, but there can be other handles pointing to this object that will be encountered later during the "walk." These are fixed up as they are found (you could imagine a hash table mapping old addresses to new ones).

There are two issues that make copy collectors inefficient. The first is the idea that you have two heaps and you slosh all the memory back and forth between these two separate heaps, maintaining twice as much memory as you actually need. Some JVMs deal with this by allocating the heap in chunks as needed and simply copying from one chunk to another.

The second issue is the copying. Once your program becomes stable it might be generating little or no garbage. Despite that, a copy collector will still copy all the memory from one place to another, which is wasteful. To prevent this, some JVMs detect that no new garbage is being generated and switch to a different scheme (this is the "adaptive" part). This other scheme is called mark and sweep, and it's what Sun's JVM uses all the time. For general use mark and sweep is fairly slow, but when you know you're generating little or no garbage it's fast.

Mark and sweep follows the same logic of starting from the stack and static storage and tracing through all the handles to find live objects. However, each time it finds a live object that object is marked by setting a flag in it, but the object isn't collected yet. Only when the marking process is finished does the sweep occur. During the sweep, the dead objects are released. However, no copying happens, so if the collector chooses to compact a fragmented heap it does so by shuffling objects around.

The "stop-and-copy" refers to the idea that this type of garbage collection is not done in the background; instead, the program is stopped while the GC occurs. In the Sun literature you'll find many references to garbage collection as a low-priority background process, but it turns out that this was a theoretical experiment that didn't work out. In practice, the Sun garbage collector is run when memory gets low. In addition, mark-and-sweep requires that the program be stopped.

As previously mentioned, in the JVM described here memory is allocated in big blocks. If you allocate a large object, it gets its own block. Strict stop-and-copy requires copying every live object from the source heap to a new heap before you could free the old one, which translates to lots of memory. With blocks, the GC can typically use dead blocks to copy objects to as it collects. Each block has a generation count to keep track of whether it's alive. In the normal case, only the blocks created since the last GC are compacted; all other blocks get their generation count bumped if they have been referenced from somewhere. This handles the normal case of lots of short-lived temporary objects. Periodically, a full sweep is made - large objects are still not copied (just get their generation count bumped) and blocks containing small objects are copied and compacted. The JVM monitors the efficiency of GC and if it becomes a waste of time because all objects are long-lived then it switches to mark-and-sweep. Similarly, the JVM keeps track of how successful mark-and-sweep is, and if the heap starts to become fragmented it switches back to stop-and-copy. This is where the "adaptive" part comes in, so you end up with a mouthful: "adaptive generational stop-and-copy mark-and-sweep."

There are a number of additional speedups possible in a JVM. An especially important one involves the operation of the loader and Just-In-Time (JIT) compiler. When a class must be loaded (typically, the first time you want to create an object of that class), the .class file is located and the byte codes for that class are brought into memory. At this point, one approach is to simply JIT all the code, but this has two drawbacks: it takes a little more time, which, compounded throughout the life of the program, can add up; and it increases the size of the executable (byte codes are significantly more compact than expanded JIT code) and this might cause paging, which definitely slows down a program. An alternative approach is lazy evaluation, which means that the code is not JIT compiled until necessary. Thus, code that never gets executed might never get JIT compiled.

Because JVMs are external to browsers, you might expect that you could benefit from the speedups of some JVMs while using any browser. Unfortunately, JVMs don't currently interoperate with different browsers. To get the benefits of a particular JVM, you must either use the browser with that JVM built in or run standalone Java applications.

Monday, February 16, 2009

Required Setups for Installing Oracle 10g on Windows XP



1) setup 1
a) goto control panel
b) goto add hardware
c) select "YES I ALLREADY CONNECTED"
d) select "ADD NEW HARDWARD DEVICE"
e) select "INSTALL MANUALLY"
f) select "NETWORK ADAPTERS"
g) select "MICROSOFT" in left window AND SELECT "MICROSOFT LOOPBACK ADAPTER" in right window
h) next -- Finish


2) setup 2
a) GOTO "NETWORK CONNECTIONS"
b) SELECT "LOCAL AREA CONNECTION (FOR LOOKUP BACK ADAPTOR)"
c) SELECT "TCP/IP" and select properties
d) select "use the following IP address"
e) enter IP address as follows:
IP address: 10.10.10.1 and Default Gateway : 10.10.10.10


Now go ahead and install Oracle 10g on your Windows XP O/S.

Tuesday, February 10, 2009

JAVA/J2EE E-books



Java__O_Reilly_-_Ant_-_The_Definitive_Guide


J2EE-Notes

SAP-ABAP Interview Q & A_1



1. Can you create a table with fields not referring to data elements?

YES. eg:- ITAB LIKE SPFLI.here we are referening to a data object(SPFLI) not data element.
What are the different types of data dictionary objects? tables, structures, views, domains, data elements, lock objects, Match code objects.

2. What should be the approach for writing a BDC program?

STEP 1: CONVERTING THE LEGACY SYSTEM DATA TO A FLAT FILE to internal table CALLED "CONVERSION".
STEP 2: TRANSFERING THE FLAT FILE INTO SAP SYSTEM CALLED "SAP DATA TRANSFER".
STEP 3: DEPENDING UPON THE BDC TYPE
i)call transaction(Write the program explicity)
ii) create sessions (sessions are created and processed.if success data will transfer).

3. What are the problems in processing batch input sessions and How is batch input process different from processing online?

PROBLEMS:
i) If the user forgets to opt for keep session then the session will be automatically removed from the session queue(log remains). However if session is processed we may delete it manually.
ii)if session processing fails data will not be transferred to SAP database table.

4. What does an extract statement do in the ABAP program?

Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements: EXTRACT. When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset EXTRACT HEADER. When you extract the data, the record is filled with the current values of the corresponding fields. As soon as the system has processed the first EXTRACT statement for a field group , the structure of the corresponding extract record in the extract dataset is fixed. You can no longer insert new fields into the field groups and HEADER. If you try to modify one of the field groups afterwards and use it in another EXTRACT statement, a runtime error occurs. By processing EXTRACT statements several times using different field groups, you fill the extract dataset with records of different length and structure. Since you can modify field groups dynamically up to their first usage in an EXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.

5. Can a transparent table exist in data dictionary but not in the data base physically?

NO. TRANSPARENT TABLE DO EXIST WITH THE SAME STRUCTURE BOTH IN THE DICTIONARY AS WELL AS IN THE DATABASE,EXACTLY WITH THE SAME DATA AND FIELDS.

6. What is the step by step process to create a table in data dictionary?

step 1: creating domains(data type, field length, range).
step 2: creating data elements(properties and type for a table field).
step 3: creating tables(SE11).

7. What is the typical structure of an ABAP/4 program?

HEADER ,BODY,FOOTER.

8. A situation: An ABAP program creates a batch input session. We need to submit the program and the batch session in back ground. How to do it?

Go to SM36 and create background job by giving job name, job class and job steps (JOB SCHEDULING)

9. What are the domains and data elements?

DOMAINS : FORMAL DEFINITION OF THE DATA TYPES.THEY SET ATTRIBUTES SUCH AS DATA TYPE,LENGTH,RANGE. DATA ELEMENT : A FIELD IN R/3 SYSTEM IS A DATA ELEMENT.

10. What is the alternative to batch input session?

Call transaction.

12. What is a batch input session?

BATCH INPUT SESSION is an intermediate step between internal table and database table. Data along with the action is stored in session ie data for screen fields, to which screen it is passed, program name behind it, and how next screen is processed.

13. What is the advantage of structures? How do you use them in the ABAP programs?

Adv:- GLOBAL EXISTANCE(these could be used by any other program without creating it again).

14. How many types of tables exist and what are they in data dictionary?

4 types of tables
i)Transparent tables - Exists with the same structure both in dictionary as well as in database exactly with the same data and fields. Both Opensql and Nativesql can be used. ii)Pool tables &
iii)Cluster tables - These are logical tables that are arranged as records of transparent tables. one cannot use native sql on these tables (only open sql).They are not managable directly using database system tools.
iv)Internal tables - .?


Sunday, February 8, 2009

Java_XML_faqs



GENERAL

Q. What is XML?

A. XML, the Extensible Markup Language, is a universal syntax for describing and structuring data independent from the application logic. XML can be used to define unlimited languages for specific industries and applications.

Q. Who developed XML?

A. XML is an activity of the World Wide Web Consortium (W3C). The XML development effort started in 1996.

A diverse group of markup language experts, from industry to academia, developed a simplified version of SGML (Standard Generalized Markup Language) for the Web. In February 1998, XML 1.0 specification became a recommendation by the W3C.

Q. What are the key benefits of XML?

A. XML promises to simplify and lower the cost of data interchange and publishing in a Web environment. XML is a text-based syntax that is readable by both computer and humans. XML offers data portability and reusability across different platforms and devices. It is also flexible and extensible, allowing new tags to be added without breaking an existing document structure. Based on Unicode, XML provides global language support.

Q. What are the applications of XML?

A. XML is poised to play a prominent role as a data interchange format in B2B Web applications such as e-commerce, supply-chain management, workflow, and application integration. Another use of XML is for structured information management, including information from databases. XML also supports media-independent publishing, allowing documents to be written once and published in multiple media formats and devices. On the client, XML can be used to create customized views into data.

Q. What is the relationship between XML and Java technology?

A. XML and the Java technology are complementary. Java technology provides the portable, maintainable code to process portable, reusable XML data. In addition, XML and Java technology have a number of shared features that make them the ideal pair for Web computing, including being industry standards, platform-independence, extensible, reusable, Web-centric, and internationalized.

Q. What are the benefits of using Java technology with XML?

A. Java technology offers a substantial productivity boost for software developers compared to programming languages such as C or C++. In addition, developers using the Java platform can create sophisticated programs that are reusable and maintainable compared to programs written with scripting languages. Using XML and Java together, developers can build sophisticated, interoperable Web applications more quickly and at a lower cost.

Q. What XML-related activities is Sun participating in?

A. Sun is actively participating in W3C working groups for XML Stylesheet/Transformation Language (XSL/T), XML Schema, Xlink, and XML Query. Sun is also participating in a number of other industry consortia including Oasis, XML.org, and Apache.

Q. Where can I find additional documentation?

A. The Java Technology & XML Documentation page has a comprehensive list of all documentation related to Java Technology and XML available on this website.

Q. Where can I send comments and suggestions?

A. For feedback on the project, please send email to xml-feedback@sun.com.

Q. Are there other Sun hosted XML mailing lists I can subscribe to?

A. For general discussion about topics related to XML technologies in the Java platform, subscribe to xml-interest@java.sun.com.




Java API for XML-Based Web Services (JAX-WS)

Q. What is the difference between JAX-RPC and JAX-WS?

A. One of the main differences between JAX-RPC and JAX-WS is the programming model.
A JAX-WS-based service uses annotations, such as @WebService, to declare web service endpoints.
Using these annotations obviates the need for deployment descriptors.
With JAX-WS, you can have a web service deployed on a Java EE-compliant application server without a single deployment descriptor.
JAX-WS also provides many additional features, such as asynchronous callback support. Refer to the JAX-WS specification for more information.

Q. Does the Java EE 5 platform support JAX-WS?

A. Yes, the Java EE 5 platform supports JAX-WS-based services (in addition to JAX-RPC-based services) and makes these services portable through JSR 109.

Q. Can a JAX-WS-based service and a JAX-RPC-based service co-exist?

A. Yes.

Q. How do I develop a simple JAX-WS-based service?

A. See this tip.

Q. Can a JAX-WS-based service that was developed and deployed on Java WSDP 2.0 be deployed and run on any Java EE 5-based platform?

A. No.

Q. How do I make my JAX-WS service that was developed and deployed on Java WSDP 2.0 portable across Java EE 5 platforms?

A. See this tip.

Q. Will a JAX-WS-based web service work with a JAX-RPC client and a JAX-RPC-based web service work with a JAX-WS client?

A. Yes.

Q. Can I have a JAX-WS web service with deployment descriptors?

A. Yes. The same deployment descriptors, such as webservices.xml, web.xml, and ejb-jar.xml, can be used, just as they were with JAX-RPC-based services. If a deployment descriptor is specified, the values specified in the annotation attributes will be overridden by the corresponding values specified in the deployment descriptors.

Q. Can the deployment descriptor values be overridden?

A. No.

Q. Do I have to specify all attributes for annotations?

A. No. Well-defined default values have been specified for all attributes of annotations.





Java API for XML Processing (JAXP)


Q. What is Java API for XML Processing (JAXP)?

The Java API for XML Processing, or "JAXP" for short, enables applications to parse and transform XML documents using an API that is independent of a particular XML processor implementation. JAXP also provides a pluggability feature which enables applications to easily switch between particular XML processor implementations.

To achieve the goal of XML processor independence, an application should limit itself to the JAXP API and avoid implementation-dependent APIs. This may or may not be easy depending on the application. JAXP includes industry standard APIs such as DOM and SAX.

The reason for the existance of JAXP is to facilitate the use of XML on the Java platform. For example, current APIs such as DOM Level 2 do not provide a method to bootstrap a DOM Document object from an XML input document, JAXP does. (When DOM Level 3 provides this functionality, a new version of the JAXP specification will probably support the new Level 3 scheme also.) Other parts of JAXP such as the javax.xml.transform portion do not have any other equivalent APIs that are XSLT processor independent.

Q. Where can I read more about JAXP?

A. See the JAXP FAQ for more information.




Java Architecture for XML Binding (JAXB)

Q. What is Java Architecture for XML Binding (JAXB)?

A. The Java Architecture for XML Binding (JAXB) simplifies the creation and maintenance of XML-enabled Java applications. JAXB provides a binding compiler and a runtime framework to support a two-way mapping between XML documents and Java objects. The binding compiler translates W3C XML Schema into one or more Java classes without requiring the developer to write complex parsing code. The schema-derived classes and binding framework enable error and validity checking of incoming and outgoing XML documents, thereby making it possible to ensure that only valid, error-free messages are accepted, processed, and generated by a system. For more information, see the Reference Implementation and the Public Draft Specification, both available for download from the JAXB homepage.

Q. What is the difference between JAXB, SAX, and DOM? Which one should I use?

A. SAX is an event-driven XML parser that is appropriate for high-speed processing of XML because it does not produce a representation of the data in memory. DOM, on the other hand, produces an in-memory data representation, which allows an application to manipulate the contents in memory. Both SAX and DOM automatically perform structure validation. An application could perform content validation with SAX and DOM, but such an application must provide the necessary extra code, which might be complicated, error-prone, and difficult to maintain.

A JAXB application can perform structure and content validation with Java classes that it generates from a schema. A JAXB application builds an in-memory data structure, like a DOM, by marshalling an XML document to build a content tree, which contains objects that are instances of the derived classes. However, unlike a DOM tree, a content tree is specific to one source schema, does not contain extra tree-manipulation functionality, allows access to its data with the derived classes' accessor methods, and is not built dynamically. For these reasons, a JAXB application uses memory more efficiently than a DOM application does. If the content of a document is more dynamic and not well-constrained, DOM and SAX are more appropriate than JAXB for processing XML content that does not have a well-known schema prior to processing the content.

Q. How does JAXB work?

A. To build a JAXB application, start with an XML schema. The beta release requires that the schema language be W3C 2001 Recommendation for XML Schema.


After obtaining an XML Schema, you build and use a JAXB application by performing these steps:

Generate the Java source files by submitting the XML Schema to the binding compiler.

You can use custom binding declarations to override the default binding of XML Schema components to Java representations

Compile the Java source code.

With the classes and the binding framework, write Java applications that:

Build object trees representing XML data that is valid against the XML Schema by either unmarshalling the data from a document or instantiating the classes you created.

Access and modify the data.

Optionally validate the modifications to the data relative to the constraints expressed in the XML Schema

Marshal the data to new XML documents.

Q. Who is involved in developing JAXB?

A. JAXB is being developed through the Java Community Process (JCP) with an expert group consisting of IBM, Software AG, BEA Systems, Hewlett-Packard, TIBCO Software Inc., Oracle, Fujitsu Limited, Breeze Factor LLC, Macromedia, Inc. and Intalio, Inc. Sun is an active member of the W3C XML Schema Working Group and is also working with other industry consortia such as OASIS and xml.org.

Q. Where can I read more about JAXB?

A. For a higher-level explanation of JAXB, refer to the JAXB chapters in the Java Web Services Tutorial. Also note that a detailed user's guide is included as part of the JAXB distribution. For a more technical and detailed description of JAXB, see the the latest version of the Specification, which you can download from the JAXB homepage. Please note that the Specification is in Adobe Acrobat PDF format. Download Adobe Acrobat for free.




Java API for XML Messaging (JAXM)

Q. What is the Java API for XML Messaging (JAXM)?

A: The Java API for XML Messaging (JAXM) is an API designed specifically for the exchange of XML business documents over the Internet. Examples of XML documents that might typically be exchanged are purchase orders, order confirmations, and invoices. You can send non-XML data by adding attachments to your message.

Q: What standards is JAXM based on?

A: JAXM is based on the Simple Object Access Protocol (SOAP) 1.1 and SOAP with Attachments specifications. JAXM also allows the implementation of standard protocols on top of the SOAP implementation, such as SOAP-RP or the ebXML Transport, Routing & Packaging V1.0 - Message Service Specification.

Q. Do I have to use the J2EE platform to use JAXM?

A: No, you are free to use the Java 2 Platform, Standard Edition (J2SE) as well as the Java 2 Platform, Enterprise Edition (J2EE). A stand-alone client (a client that does not use a messaging provider) can use the J2SE platform to send request-response messages to Web services that process request-response messages. This requires no deployment or configuration from the client, so it is easy to do.

Q. What is a messaging provider?

A: A messaging provider is a service that works with the messaging infrastructure to route and transmit messages. What it does is completely transparent to the client sending or receiving a message. An application that uses a messaging provider must use a connection that goes to the provider, called a ProviderConnection object in the JAXM API. Using a messaging provider also requires some deployment and configuration. Normally, a client using a messaging provider runs in a container -- either a servlet or a J2EE container. At deployment time, the client needs to give the container information about the messaging provider. In the future, there will be a deployment tool that makes this easy.

Q. Do I have to use a messaging provider?

A: No. You need to use a messaging provider only when your application requires one-way (asynchronous) messaging. In this type of messaging, a message is sent to a recipient as one operation, and the recipient responds at some later time in a different operation. If you application uses a request-response style of messaging, in which the response to a message is sent back as part of the same operation, you do not need a messaging provider. When you do not use a messaging provider, you use a SOAPConnection object, which supports the simpler request-response messaging model.

Q. Can a JAXM message be routed to more than one destination?

Yes. Intermediate recipients can be specified in a message's header. One way this capability can be used is to automate business processes. For example, two businesses can agree to the conditions under which they exchange XML documents so that they can implement the automatic generation of messages and responses. Assume that two businesses have an arrangement specifying that purchase orders will go first to the order entry department, then to the order confirmation department, then to the shipping department, and finally to the billing department. Each department is an intermediate recipient (called an actor). After an actor has done its part, it removes everything in the header that relates to it and sends the message on to the next actor listed in the header.

Q. Can I use ebXML headers in a JAXM message?

A: Yes, you can use ebXML headers if you use an ebXML profile that is implemented on top of SOAP. A profile is a standard protocol, such as ebXML TRP or SOAP-RP, that works on top of SOAP to give you added functionality. You need to use a messaging provider that supports the profile, and you need to arrange with your recipients to use the same profile.




Java API for XML Registries (JAXR)

Q. What is the Java API for XML Registries (JAXR)?

A. The Java API for XML Registries (JAXR) API provides a uniform and standard Java API for accessing different kinds of XML Registries. XML registries are an enabling infrastructure for building, deployment, and discovery of Web services.

Q. What is the relationship between the JAXR API and other XML APIs?

A. Implementations of JAXR providers may use the Jav API for XML-Based RPC (JAX-RPC) for communication between JAXR providers and registry providers that export a SOAP based RPC-like interface (for example, UDDI).

Implementations of JAXR providers may use the Java API for XML Messaging (JAXM) API for communication between JAXR providers and registry providers that export an XML Messaging-based interface (for example, ebXML TRP).

The Java API for XML Processing (JAXP) and Java Architecture for XML Binding (JAXB) may be used by implementers of JAXR providers and JAXR clients for processing XML content that is submitted to or retrieved from the Registry.

Q. Why do we need a new JAXR API when we have the Java Naming and Directory Interface (JNDI)?

A. The JNDI API was designed with a very different set of requirements from the JAXR API. Both are abstraction APIs over existing specifications. However, the abstraction in directory services differs considerably from that of XML Registries used for publishing and discovery of Web services. The JAXR API needs richer metadata capabilities for classification and association, as well as richer query capabilities.

Q. Would it not be better to have enhanced the JNDI API with the added functionality of the JAXR API?

A. That option was considered. Meeting the additional requirements of XML Registries requires an elaborate information model. The JNDI API has an existing information model that is constrained by design to address the requirements for directory services. Extending the JNDI API would overly constrain the JAXR API and would create backward compatibility issues for the JNDI API.

Q. What is the purpose of Association in the JAXR information model? It is not used anywhere in the API.

A. An Association relates two RegistryObjects to each other. An Association may be defined between two objects in the registry and submitted using the GenericLifeCycleManager's saveObjects method.

Q. What is the purpose of Classification in the JAXR information model? It is not used anywhere in the API.

A. A Classification classifies a RegistryObject. A Classification may be defined for a RegistryObject and submitted using the GenericLifeCycleManager's saveObjects method.

Q. Why is JAXR an abstraction API and not targeted to a specific registry such as UDDI or ebXML?

A. An abstraction-based JAXR API gives developers the ability to write registry client programs that are portable across different target registries. This is consistent with the Java philosophy of Write Once, Run Anywhere. It also enables value-added capabilities beyond what the underlying registries are capable of. For example, a non-JAXR UDDI client does not have the ability to do taxonomy browsing and taxonomy-aware smart queries, which are available to a JAXR client for UDDI.

Q. Why does the JAXR API not use UDDI terms and concepts?

A. The JAXR API is not specific to UDDI or any other registry specification. It is an abstraction API that covers multiple specifications. It is designed to enable developer choice in the use of a Web service registry and/or repository. The JAXR API uses UDDI terms and concepts when they fit the JAXR information model (for example, Service, ServiceBinding, and method names in BusinessQueryManager and BusinessLifeCycleManager).

Q. Why did the JAXR information model use the ebXML Registry Information Model as its basis rather than the UDDI data structures?

A. The JAXR API is designed to support multiple registries. The ebXML Registry Information Model is more generic and extensible than the UDDI data structures. Because of this characteristic, it was possible to extend the ebXML Registry Information Model to satisfy the needs of UDDI and other registries.

Q. Why was the JAXR information model not designed from the ground up?

A. Information models take time to develop. It was easier to start with an existing information model and improve upon it.




Java API for XML-Based RPC (JAX-RPC)

Q. What is the Java API for XML-Based RPC (JAX-RPC)?

A. The Java API for XML-Based RPC (JAX-RPC) enables Java technology developers to build Web applications and Web services incorporating XML-based RPC functionality according to the SOAP (Simple Object Access Protocol) 1.1 specification.

Q. How does JAX-RPC use SOAP?

A. Please refer to JSR-101.

Q. What is RPC?

A. RPC stands for remote procedure call, a mechanism that allows a client to execute procedures on other systems. The RPC mechanism is often used in a distributed client/server model. The server defines a service as a collection of procedures that may be called by remote clients.

Q. How is XML related to RPC?

A. The remote procedure call is represented by an XML-based protocol, such as SOAP. In addition to defining envelope structure and encoding rules, the SOAP specification defines a convention for representing remote procedure calls and responses.

Q. What does JAX-RPC have to do with Web services?

A. An XML-based RPC server application can define, describe, and export a Web service as an RPC-based service. WSDL (Web Service Description Language) specifies an XML format for describing a service as a set of endpoints operating on messages. With the JAX-RPC API, developers can implement clients and services described by WSDL.

Q. What are the modes of interaction between clients and JAX-RPC services?

A. There are three different modes:

Synchronous Request-Response: The client invokes a remote procedure and blocks until it receives a return or an exception.


One-Way RPC: The client invokes a remote procedure but it does not block or wait until it receives a return. The runtime system for the JAX-RPC client may throw an exception.


Non-Blocking RPC Invocation: The client invokes a remote procedure and continues processing in the same thread without waiting for a return. Later, the client processes the remote method return by blocking for the receive or polling for the return.


Q. Can a remote method call or response carry service context information?

A. Yes. For example, it may carry a unique transaction identifier or digital signature.

Q. Why doesn't xrpcc generate a WSDL file?

A. The xrpcc tool does in fact generate the WSDL file, but due to a bug it gets deleted along with the source files if the -keep option is not specified. You can use the -keep option which will cause xrpcc to not delete the WSDL or .java source files. If you also use the -s sourcepath option, all of the source files will be placed in the sourcepath directory and then you can easily delete them. The WSDL file will still be placed in the current directory or the directory specified by the -d option.




Java 2 Platform, Enterprise Edition

Q. Does the Java 2 Platform, Enterprise Edition (J2EE) use XML?

A. The Java 2 Platform, Enterprise Edition (J2EE) promotes the use of XML for data messaging between loosely-coupled business systems. The J2EE reference implementation includes the Java API for XML Parsing (JAXP).

JavaServer Pages (JSP) can generate and consume XML between multi-tier servers or between server and client. Java Message Service (JMS) provides an asynchronous transport mechanism for XML data messaging. Enterprise JavaBeans (EJB) offers a robust, synchronous transport mechanism by allowing a business service object to be invoked by XML tags. EJB also uses XML to describe its deployment properties, such as transactions and security.

Q. Can I generate dynamic XML documents using JSP pages?

A. JSP pages enables the authoring of XML pages. XML pages can be generated using JSP pages, which include elements to produce the dynamic portions of the document. The JSP specification includes a powerful tag extension mechanism that can be used to perform XML-based operations, such as applying an XSLT transformation to an XML document.

Friday, February 6, 2009

XML Interview Questions

1. What is XML?
XML, Extensible Markup Language, is an open, text based markup language that provides structural and semantic information to data.

2. Describe the differences between XML and HTML?
Differences between XML and HTML:
XML
► User definable tags
► Content driven
► End tags required for well formed documents
► Quotes required around attributes values
► Slash required in empty tags
HTML
► Defined set of tags designed for web display
► Format driven
► End tags not required
► Quotes not required
► Slash not required

3. List the rules to be followed by an XML document?
They must have a root tag, the document should be well formed and the tags should be properly closed, since XML is case sensitive, one should take care

4. Define DTD (Document Type definition)?
XML DTD is a rule book that an XML document follows. Once DTD is ready, you can create number of XML documents following the same rules

5. What is a CDATA section in XML?
The term CDATA is used when you don’t want some text data to be parsed by the XML parser.

6. What is XSL?
XSL is a language for expressing style sheets. An XSL style sheet is a file that describes the way to display an XML document

7. What is XQuery?
Xquery is a query language that is used to retrieve data from XML documents

8. What is XMLA?
It is a Microsoft specified XML-messaging-based protocol for exchanging analytical data between client applications and servers

9. What is DOM?
DOM is an interface-oriented Application Programming Interface. It allows for navigation of the entire document

10. What is XML Namespace?
An XSL sheet or a document may have duplicate elements and attributes. Therefore, the XML namespaces define a way to distinguish between

11. What is XML data binding?
XML data binding refers to the process of representing the information in an XML document as an object in computer memory

12. What is an XML encoding error?
XML documents can contain non ASCII characters, like Norwegian æ ø å , or French ê è é which introduce errors

13. What are XML Serialization and Binary Serialization?
XML Serialization makes it possible to convert any common language runtime objects into XML documents or streams and vise versa.

14. How do you load data from XML file to a ORACLE table?
You need to first create a table in oracle that matches with the fields of the XML data .

15. What are XML indexes and secondary XML indexes?
The primary XML index is a B+tree and is useful because the optimizer creates a plan for the entire query.

16. What is the purpose of FOR XML in SQL Server?
SQL Server 2000 provides the facility to retrieve data in the form of XML with the help of the FOR XML clause appended to the end of a SELECT statement.

17. What is the difference between SAX parser and DOM parser?
DOM spec defines an object-oriented hierarchy.
The DOM parser creates an internal tree based on the hierarchy of the XML data.
Tree stays in memory until released. The DOM parser is more memory intensive. DOM Parser’s advantage is that it is simple. Pairs nicely with XSLT.

SAX spec defines an event based approach, calling handler functions whenever certain text nodes or processing instructions are found. These events include the start and end of the document, finding a text node, finding child elements, and hitting a malformed element. SAX development is more challenging. SAX can parse gigabytes worth of XML without hitting resource barriers. It’s also faster and more complex. Better for huge XML documents. Best suited for sequential-scan applications.

18. What is the difference between Schema and DTD?
Schema might out phase DTD. XML schemas are in XML. XML Schema has a lot of built-in data types including xs:string,xs:decimal, xs:integer, xs:boolean, xs:date, xs:time. XML schemas can be edited with Schema files, parsed with XML parser, manipulated with XML DOM, and transformed with XSLT.
The building blocks of DTD include elements, attributes, entities, PCDATA, and CDATA.

19. How do you parse/validate the XML document?
By using a SAXParser, DOMParser, or XSDValidator.

20. What is XML Namespace?
Defining a namespace to avoid confusion involves using a prefix and adding an xmlns attribute to the tag to give the prefix a qualified name associated with the namespace. All child elements with the same prefix are associated with the namespace defined in the start tag of an element.

21. What is Xpath?
XPath is a language for addressing parts of an XML document, designed to be used by both XSLT and XPointer.

22. What is XML template?
A style sheets describes transformation rules
A transformation rule consists of a pattern + a template
Pattern: a configuration in the source tree
Template: a structure to be instantiated in the result tree
When a pattern is matched in the source tree, the corresponding pattern is generated in the result tree

23. How would you produce PDF output using XSL’s?
1.transform xml into xsl-fo doc using xslt, or DOM or SAX
2.process xsl-fo using a Formatter to convert xsl-fo into a pdf.

24. What are the steps to transform XML into HTML using XSL?
An XSLT processor may output the result tree as a sequence of bytes.The xsl:output element allows stylesheet authors to specify how they wish the result tree to be output. If an XSLT processor outputs the result tree, it should do so as specified by the xsl:output element; however, it is not required to do so.The method attribute on xsl:output identifies the overall method that should be used for outputting the result tree.
The html output method outputs the result tree as HTML;

25. What is XSL?
In addition to XSLT, XSL includes an XML vocabulary for specifying formatting. XSL specifies the styling of an XML document by using XSLT to describe how the document is transformed into another XML document that uses the formatting vocabulary.

26. What is XSLT?
A language for transforming XML documents into other XML documents. XSLT is designed for use as part of XSL, which is a stylesheet language for XML.

Wednesday, February 4, 2009

.NET Interview Questions

1. What is a static class?

A static class is a class which can not be instantiated using the ‘new’ keyword. They also only contain static members, are sealed and have a private constructor.


2. What is static member?

A static member is a method, field, property or event that can be called without creating an instance of its defining class. Static members are particularly useful for representing calculations and data that are independent of object state.

3. What is static function?

A static function is another term for a static method. It allows you to execute the function without creating an instance of its defining class. They are similar to global functions. An example of a static function could be: ConvertFromFarenheitToCelsius with a signature as follows:

public static double ConvertFromFarenheitToCelsius (string valToConvert){//add code here}

4. What is static constructor?

A static constructor has a similar function as a normal constructor i.e. it is automatically called the first time a class is loaded. The differences between a conventional constructor are that it cannot be overloaded, cannot have any parameters nor have any access modifiers and must be preceded by thekeyword static. In addition, a class with a static constructor may only have static members.

5. How can we inherit a static variable?

6. How can we inherit a static member?

When inheriting static members there is no need to instantiate the defining class using the ‘new’ keyword.
public class MyBaseClass{MyBaseClass(){}public static void PrintName(){}
}
public class MyDerivedClass : MyBaseClass{MyDerivedClass (){}
public void DoSomething(){MyBaseClass.GetName();}
}


7. Can we use a static function with a non-static variable?

No.

8. How can we access static variable?

By employing the use of a static member field as follows:public class CashSales{//declare static member fieldprivate static int maxUnitsAllowed = 50;
//declare method to return maximum number of units allowed
public static int GetMaxUnitsAllowed (){Return maxUnitsAllowed;}
}The static field can now be accessed by simply doing CashSales.GetMaxUnitsAllowed(). No need to create an instance of the class.

9. Why main function is static?

Because it is automatically loaded by the CLR and initialised by the runtime when the class is first loaded. If it wasn’t static an instance of the class would first need to be created and initialised.

10. How will you load dynamic assembly?How will create assemblies at run time?

Load assembly:By using classes from the System.Reflection namespace.Assembly x = Assembly.LoadFrom( “LoadMe.dll” );
Create assembly;Use classes from System.CodeDom.Compiler;

11. What is Reflection?

The System.Reflection namespace provides us with a series of classes that allow us to interrogate the codebase at run-time and perform functions such as dynamically load assemblies, return property info e.t.c.

12. If I have more than one version of one assembly, then how will I use old version (how/where to specify version number?) in my application?

The version number is stored in the following format: …. The assembly manifest can then contain a reference to which version number we want to use.

13. How do you create threading in.NET? What is the namespace for that?

System.Threading;
//create new thread using the thread class’s constructor
Thread myThread = new Thread(new ThreadStart (someFunction));

14. What do you mean by Serialize and MarshalByRef?

Serialization is the act of saving the state of an object so that it can be recreated (i.e deserialized) at a later date.The MarshalByRef class is part of the System.Runtime.Remoting namespace and enables us to access and use objects that reside in different application domains. It is the base class for objects that need to communicate across application domains. MarshalByRef objects are accessed directly within their own application domain by using a proxy to communicate. With MarshalByValue the a copy of the entire object is passed across the application domain

15. What is the difference between Array and LinkedList?

An array is a collection of the same type. The size of the array is fixed in its declaration.A linked list is similar to an array but it doesn’t have a limited size.

16. What is Asynchronous call and how it can be implemented using delegates?

A synchronous call will wait for a method to complete before program flow is resumed. With an asynchronous call the program flow continues whilst the method executes.
//create objectSomeFunction objFunc = new SomeFunction();
//create delegateSomeDelegate objDel = new SomeDelegate(objFunc.FunctionA);
//invoke the method asynchronously (use interface IAsyncResult)IAsyncResult asynchCall = SomeDelegate.Invoke();

17. How to create events for a control? What is custom events? How to create it?

An event is a mechanism used in a class that can be used to provide a notification when something interesting happens. (typical evens in a windows application include: change text in textbox, double click or click a button, select an item in dropdown box).
A custom event is an event created by the user that other developers can use. For example assuming that we have a CashTransaction class and we have a bank balance property in that class. We may want to set-up an event that provides a notification when the bank balance drops below a certain amount. In order to produce an event the process would be roughly as follows:
Create the class for the event derived from EventArgs.Create a delegate with a return type of void.Create a class containing the method that will activate the event.Create a class with methods to handle the event.

18. If you want to write your own dot net language, what steps you will you take care?

We will need to ensure that the high level code is compiled to MSIL (Microsoft intermediate language) so that it can be interpreted by the CLR.

19. Describe the difference between inline and code behind - which is best in a loosely coupled solution?

The term ‘code behind’ refers to application code that is not embedded within the ASPX page and is separated out into a separate file which is then referenced from the ASPX page. Inline code is the traditional ASP architectural model where business logic code was embedded within the ASP page. Separating the business logic code from the presentation layer offers several advantages:
1) It allows graphic designers and web developers to work on the presentation layer whilst the application developers concentrate on the business logic.

2) The codebehind file is compiled as a single dll increasing the efficiency of the application

3) The codebehind model offers a true OO development platform

4) It speeds up development time as it allows developers to fully maximise the features of the .NET framework such as Cahing, ViewState, Session, Smart Navigation etc.

5) Code is much easier to maintain and susceptible for change.

6) The compiler and VS.NET provides much better support for error checking, intellisense and debugging when using the code behind model.

20. How dot net compiled code will become platform independent?

The reason for .NET was to cater for multiples languages on a single windows platform whereas the aim of Java was to be a single language on multiple platforms. The only way that .NET can be platform independent is if there is a version of the .NET framework installed on the target machine.

21. Without modifying source code if we compile again, will it be generated MSIL again?

No.

22. How does you handle this COM components developed in other programming languages in.NET?

Use TlbImp.exe to import the COM types into your .NET project. If no type library for the COM component then use System.Runtime.InteropServices

22. How does you handle this COM components developed in other programming languages in.NET?

Use TlbImp.exe to import the COM types into your .NET project. If no type library for the COM component then use System.Runtime.InteropServicesuse RegAsm.exe to call a .NET developed component in a COM application.

23. How CCW (Com Callable Wrapper) and RCW (Runtime Callable Wrappers) works?

CCW: When a COM application calls a NET object the CLR creates the CCW as a proxy since the COM application is unable to directly access the .NET object.RCW: When a .NET application calls a COM object the CLR creates the RCW as a proxy since the .NET application is unable to directly access the .COM object.

24. What are the new thee features of COM+ services, which are not there in COM (MTS)?

Role based security.Neutral apartment threading.New environment called context which defines the execution environment

25. What are the differences between COM architecture and.NET architecture?

.Net architecture has superseded the old COM architecture providing a flexible rapid application development environment which can be used to create windows, web and console applications and web services. .NET provides a powerful development environment that can be used to create objects in any .NET compliant language. .NET addresses the previous problems of dll hell with COM by providing strongly named assemblies and side-by-side execution where two assemblies with the same name can run on the same box.

26. Can we copy a COM dll to GAC folder?

No. It only stores .NET assemblies.

28. Can you explain what inheritance is and an example of when you might use it?

Inheritance is a fundamental feature of any OO language. It allows us to inherit the members and attributes from a base class to a new derived class. This leads to increased code reusability and also makes applications easier to develop, maintain and extend as the new derived class can contain new features not available in the base class whilst at the same time preserving the attributes inherited from the base class.

29. How can you write a class to restrict that only one object of this class can be created (Singleton class)?

Use the singleton design pattern.public sealed class Singleton{static readonly Singleton Instance=new Singleton();
static Singleton(){}
Singleton(){}
public static Singleton Instance{get{return Instance;}}}

30. What are virtual destructors?

A constructor can not be virtual but a destructor may. Use virtual destructors when you want to implement polymorphic tearing down of an object.

31. What is close method? How it different from Finalize and Dispose?

Finalise is the process that allows the garbage collector to clean up any unmanaged resources before it is destroyed.The finalise method can not be called directly; it is automatically called by the CLR. In order to allow more control over the release of unmanaged resources the .NET framework provides a dispose method which unlike finalise can be called directly by code.Close method is same as dispose. It was added as a convenience.

32. What is Boxing and UnBoxing?

Boxing is the process of converting a value type to a reference type. More specifically it involves encapsulating a copy of the object and moving it from stack to heap. Unboxing is the reverse process.

33. What is check/uncheck?

checked: used to enable overflow checking for arithmetic and conversion functions.unchecked: used to disable overflow checking for arithmetic and conversion functions.

Monday, February 2, 2009

JAVA/Swing Quest

1.What is a class?
A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind.

2.What is a object?
An object is a software bundle of variables and related methods.An instance of a class depicting the state and behavior at that particular time in real world.

3.What is a method?
Encapsulation of a functionality which can be called to perform specific tasks.

4.What is encapsulation? Explain with an example.
Encapsulation is the term given to the process of hiding the implementation details of the object. Once an object is encapsulated, its implementation details are not immediately accessible any more. Instead they are packaged and are only indirectly accessible via the interface of the object

5.What is inheritance? Explain with an example.
Inheritance in object oriented programming means that a class of objects can inherit properties and methods from another class of objects.

6.What is polymorphism? Explain with an example.
In object-oriented programming, polymorphism refers to a programming language’s ability to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes. For example, given a base class shape, polymorphism enables the programmer to define different area methods for any number of derived classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the area method to it will return the correct results. Polymorphism is considered to be a requirement of any true object-oriented programming language

7.Is multiple inheritance allowed in Java?
No, multiple inheritance is not allowed in Java.

8.What is interpreter and compiler?
Java interpreter converts the high level language code into a intermediate form in Java called as bytecode, and then executes it, where as a compiler converts the high level language code to machine language making it very hardware specific

9.What is JVM?
The Java interpreter along with the runtime environment required to run the Java application in called as Java virtual machine(JVM)

10.What are the different types of modifiers?
There are access modifiers and there are other identifiers. Access modifiers are public, protected and private. Other are final and static.

11.What are the access modifiers in Java?
There are 3 access modifiers. Public, protected and private, and the default one if no identifier is specified is called friendly, but programmer cannot specify the friendly identifier explicitly.

12.What is a wrapper class?
They are classes that wrap a primitive data type so it can be used as a object

13.What is a static variable and static method? What’s the difference between two? The modifier static can be used with a variable and method. When declared as static variable, there is only one variable no matter how instances are created, this variable is initialized when the class is loaded. Static method do not need a class to be instantiated to be called, also a non static method cannot be called from static method.

14.What is garbage collection?
Garbage Collection is a thread that runs to reclaim the memory by destroying the objects that cannot be referenced anymore.

15.What is abstract class?
Abstract class is a class that needs to be extended and its methods implemented, aclass has to be declared abstract if it has one or more abstract methods.

16.What is meant by final class, methods and variables?
This modifier can be applied to class method and variable. When declared as final class the class cannot be extended. When declared as final variable, its value cannot be changed if is primitive value, if it is a reference to the object it will always refer to the same object, internal attributes of the object can be changed.

17.What is interface?
Interface is a contact that can be implemented by a class, it has method that need implementation.

18.What is method overloading?
Overloading is declaring multiple method with the same name, but with different argument list.

19.What is method overriding?
Overriding has same method name, identical arguments used in subclass.

20.What is singleton class?
Singleton class means that any given time only one instance of the class is present, in one JVM.

21.What is the difference between an array and a vector?
Number of elements in an array are fixed at the construction time, whereas the number of elements in vector can grow dynamically.

22.What is a constructor?
In Java, the class designer can guarantee initialization of every object by providing a special method called a constructor. If a class has a constructor, Java automatically calls that constructor when an object is created, before users can even get their hands on it. So initialization is guaranteed.

23.What is casting?
Conversion of one type of data to another when appropriate. Casting makes explicitly converting of data.

24.What is the difference between final, finally and finalize?
The modifier final is used on class variable and methods to specify certain behaviour explained above. And finally is used as one of the loop in the try catch blocks, It is used to hold code that needs to be executed whether or not the exception occurs in the try catch block. Java provides a method called finalize( ) that can be defined in the class. When the garbage collector is ready to release the storage ed for your object, it will first call finalize( ), and only on the next garbage-collection pass will it reclaim the objects memory. So finalize( ), gives you the ability to perform some important cleanup at the time of garbage collection.

25.What is are packages?
A package is a collection of related classes and interfaces providing access protection and namespace management.

26.What is a super class and how can you call a super class?
When a class is extended that is derived from another class there is a relationship is created, the parent class is referred to as the super class by the derived class that is the child. The derived class can make a call to the super class using the keyword super. If used in the constructor of the derived class it has to be the first statement.

27.What is meant by a Thread?
Thread is defined as an instantiated parallel process of a given program.

28.What is multi-threading?
Multi-threading as the name suggest is the scenario where more than one threads are running.

29.What are two ways of creating a thread? Which is the best way and why?
Two ways of creating threads are, one can extend from the Java.lang.Thread and can implement the rum method or the run method of a different class can be called which implements the interface Runnable, and the then implement the run() method. The latter one is mostly used as first due to Java rule of only one class inheritance, with implementing the Runnable interface that problem is sorted out.

30.What is deadlock?
Deadlock is a situation when two threads are waiting on each other to release a resource. Each thread waiting for a resource which is held by the other waiting thread. In Java, this resource is usually the object lock obtained by the synchronized keyword.

31.What are the three types of priority?
MAX_PRIORITY which is 10, MIN_PRIORITY which is 1, NORM_PRIORITY which is 5.

32.What is the use of synchronizations?
Every object has a lock, when a synchronized keyword is used on a piece of code the, lock must be obtained by the thread first to execute that code, other threads will not be allowed to execute that piece of code till this lock is released.

Swings

1) Can a class be it’s own event handler? Explain how to implement this.
Answer: Sure. an example could be a class that extends Jbutton and implements ActionListener. In the actionPerformed method, put the code to perform when the button is pressed.

2) Why does JComponent have add() and remove() methods but Component does not?
Answer: because JComponent is a subclass of Container, and can contain other components and jcomponents.

3) How would you create a button with rounded edges?
Answer: there’s 2 ways. The first thing is to know that a JButton’s edges are drawn by a Border. so you can override the Button’s paintComponent(Graphics) method and draw a circle or rounded rectangle (whatever), and turn off the border. Or you can create a custom border that draws a circle or rounded rectangle around any component and set the button’s border to it.

4) If I wanted to use a SolarisUI for just a JTabbedPane, and the Metal UI for everything else, how would I do that?
Answer: in the UIDefaults table, override the entry for tabbed pane and put in the SolarisUI delegate. (I don’t know it offhand, but I think it’s "com.sun.ui.motiflookandfeel.MotifTabbedPaneUI" - anything simiar is a good answer.)

5) What is the difference between the ‘Font’ and ‘FontMetrics’ class?
Answer: The Font Class is used to render ‘glyphs’ - the characters you see on the screen. FontMetrics encapsulates information about a specific font on a specific Graphics object. (width of the characters, ascent, descent)

6) What class is at the top of the AWT event hierarchy?
Answer: java.awt.AWTEvent. if they say java.awt.Event, they haven’t dealt with swing or AWT in a while.

7) Explain how to render an HTML page using only Swing.
Answer: Use a JEditorPane or JTextPane and set it with an HTMLEditorKit, then load the text into the pane.

8) How would you detect a keypress in a JComboBox?
Answer: This is a trick. most people would say ‘add a KeyListener to the JComboBox’ - but the right answer is ‘add a KeyListener to the JComboBox’s editor component.’

9) Why should the implementation of any Swing callback (like a listener) execute quickly?
A: Because callbacks are invoked by the event dispatch thread which will be blocked processing other events for as long as your method takes to execute.

10) In what context should the value of Swing components be updated directly?
A: Swing components should be updated directly only in the context of callback methods invoked from the event dispatch thread. Any other context is not thread safe?

11) Why would you use SwingUtilities.invokeAndWait or SwingUtilities.invokeLater?
A: I want to update a Swing component but I’m not in a callback. If I want the update to happen immediately (perhaps for a progress bar component) then I’d use invokeAndWait. If I don’t care when the update occurs, I’d use invokeLater.

12) If your UI seems to freeze periodically, what might be a likely reason?
A: A callback implementation like ActionListener.actionPerformed or MouseListener.mouseClicked is taking a long time to execute thereby blocking the event dispatch thread from processing other UI events.

13) Which Swing methods are thread-safe?
A: The only thread-safe methods are repaint(), revalidate(), and invalidate()

14) Why won’t the JVM terminate when I close all the application windows?
A: The AWT event dispatcher thread is not a daemon thread. You must explicitly call System.exit to terminate the JVM.

Q1: What are the advantages of OOPL?
Ans: Object oriented programming languages directly represent the real life objects. The features of OOPL as inhreitance, polymorphism, encapsulation makes it powerful.

Q2: What do mean by polymorphisum, inheritance, encapsulation?
Ans: Polymorhisum: is a feature of OOPl that at run time depending upon the type of object the appropriate method is called.
Inheritance: is a feature of OOPL that represents the "is a" relationship between different objects(classes). Say in real life a manager is a employee. So in OOPL manger class is inherited from the employee class.
Encapsulation: is a feature of OOPL that is used to hide the information.

Q3: What do you mean by static methods?
Ans: By using the static method there is no need creating an object of that class to use that method. We can directly call that method on that class. For example, say class A has static function f(), then we can call f() function as A.f(). There is no need of creating an object of class A.

Q4: What do you mean by virtual methods?
Ans: virtual methods are used to use the polymorhism feature in C++. Say class A is inherited from class B. If we declare say fuction f() as virtual in class B and override the same function in class A then at runtime appropriate method of the class will be called depending upon the type of the object.

Q5: Given two tables Student(SID, Name, Course) and Level(SID, level) write the SQL statement to get the name and SID of the student who are taking course = 3 and at freshman level.
Ans: SELECT Student.name, Student.SID
FROM Student, Level
WHERE Student.SID = Level.SID
AND Level.Level = "freshman"
AND Student.Course = 3;

Q6: What are the disadvantages of using threads?
Ans: DeadLock.

Q7: Write the Java code to declare any constant (say gravitational constant) and to get its value
Ans: Class ABC
{
static final float GRAVITATIONAL_CONSTANT = 9.8;
public void getConstant()
{
system.out.println("Gravitational_Constant: " + GRAVITATIONAL_CONSTANT);
}
}

Q8: What do you mean by multiple inheritance in C++ ?
Ans: Multiple inheritance is a feature in C++ by which one class can be of different types. Say class teachingAssistant is inherited from two classes say teacher and Student.

Q9: Can you write Java code for declaration of multiple inheritance in Java ?
Ans: Class C extends A implements B
{
}

SQL Basics


1.Types of joins?

Cartesian Products:

A Cartesian product is formed when:
A join condition is omitted
A join condition is invalid
All rows in the first table are joined to all rows in the second table
To avoid a Cartesian product, always include a valid join condition in a WHERE Clause.
Ex:
SELECT ename,dname dept_name FROM emp,dept;

Equi-join:

ATo determine an employee’s department name, we compare the value in the DEPTNO column in the EMP table with the DEPT NO values in the DEPT table. The relationship between the EMP and DEPT tables is an equijoin ie,values in the DEPT NO column on both tables must be equal. Frequently, this type of join involves primary and foreign key complements.Note: Equi-joins are also called simple joins or inner joins.
Ex:
SELECT e.empno,e.ename,e.deptno,d.deptno FROM emp e,dept d WHERE e.deptno = d.deptno;
Non-Equijoins:
A Non-equijoin is a join condition containing something other than a equality operator. The relationship between the EMP table and the SALGRADE table has an example of a non-equijoin. A relationship between the two tables is that the SALARY column in the EMP table must be between the values in the LOSAL and HISAL columns of the SALGRADE table. The relationship is obtained using an operator other than equals(=).
Ex:
SELECT e.ename,e.sal,s.grade FROM emp e, salgrade s WHERE e.sal BETWEEN s.losal AND s.hisal;

Outer Joins:

The missing rows can be returned if an outer join operator is used in the join condition. The operator is a plus sign enclosed in parentheses(+), and it is placed on the “side” of the join that is deficient in information. This operator has the effect of creating one or more null rows, to which one or more rows from the nondeficient can be joined.
Syntax:
Table1.column = is the condition that joins(or relates) the table together.Table2.column (+) is the outer join symbol which can be placed on either side of the WHERE clause condition, but not on both sides.
Ex:
SELECT e.ename,e.deptno,d.dname FROM emp e,dept d WHERE e.deptno(+) = d.deptno;

Self Joins:

To find the name of each emp’s manager, we need to join the emp table to itself ,or perform a self join.


2.INNER Versus OUTER Joins?

In SQL:1999, the join of two tables returning only matched rows is an inner join.A Join between two tables that returns the results of the inner join as well as unmatched rows left (or right) tables is a left (or right) outer join.A Join between two tables that returns the results of an inner join as well as the results of a left and right join is a full outer join.


3. Difference between having and where clause?

Where clause is used for restricting rows that are to be retrieved by a query and where as Having clause is used for restricting groups.

4. Difference between Left outer join and Right outer join?

For a RIGHT OUTER JOIN, the left operand cannot be a join expression, a view, or a (query).For a LEFT OUTER JOIN, the right operand cannot be a join expression. It can, however, be a view or a (query).

5. Normalization and de normalization?

Normalization of data can be looked on as a process during which unsatisfactory relation schemas are decomposed by breaking up their attributes into smaller relation schemas that possess desirable properties. One objective of the original normalization process is to ensure that the update anomalies do not occur.
Denormalization: As the name indicates, denormalization is the reverse process of normalization. It's the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced.

6. What is Referential Integrity?

A rule defined on a key (a column or set of columns) in one table that guarantees that the values in that key match the values in a key in a related table (the referenced value).The FOREIGN KEY OR referential integrity constraint, designates a column or combination of columns as a foreign key and establishes a relationship between a primary key or a unique key in the same table or a different table.

7. What’s a Primary Key?

Primary key constraints can be defined at the column level or table level. A composite PRIMARY KEY is created by using the table – level definition. A table can have only one primary key but can have several unique constraints.

8. What is a view? where will you use views?

A view is a logical table based on a table or another view. A view contains no data of its own but is like a window through which data from tables can be viewed or changed. The tables on which a view is based are called base tables.
Usage of views:
a)To restrict data access
b)To make complex queries easy
c)To provide data independence
d)To present different views or the same data

9. What are Indexes, types of indexes, how data is stored?

An oracle server index is a schema object that can speed up the retrival or rows by using a pointer.Two types or indexes can be created. One type is a unique index: the oracle server automatically creates this index when you define a column in a table to have a PRIMARY KEY or a UNIQUE key constraint. The name of the index is the name given to the constraint.The other type of index is a nonunique index, which a user can create. For example we can create a foreign key column index for a join in a query to improve retrieval speed.

10. Why there is a performance difference between two similar queries that uses UNION and UNION ALL?

The UNION operator returns all rows selected by either query. Use the UNION operator to return all rows from multiple tables and eliminate any duplicate rows.
Use the UNION ALL operator to return all rows from multiple queries.
Unlike UNION, duplicate rows are not eliminated and the output is not sorted by default. The DISTINCT keyword cannot be used. 11. Explain Third normalization form with an example

A relation is in third normal form (3NF) if and only if it is in 2NF and every nonkey attribute is nontransitively dependent on the primary key.
Third normal form is violated when a non-key field is a fact about another non-key field, as in ------------------------------------ EMPLOYEE DEPARTMENT LOCATION ============------------------------The EMPLOYEE field is the key. If each department is located in one place, then the LOCATION field is a fact about the DEPARTMENT -- in addition to being a fact about the EMPLOYEE. The problems with this design are the same as those caused by violations of second normal form: The department's location is repeated in the record of every employee assigned to that department. If the location of the department changes, every such record must be updated. Because of the redundancy, the data might become inconsistent, with different records showing different locations for the same department. If a department has no employees, there may be no record in which to keep the department's location. To satisfy third normal form, the record shown above should be decomposed into the two records: ------------------------- ------------------------- EMPLOYEE DEPARTMENT DEPARTMENT LOCATION ============------------- ==============-----------

12. What are constraints?

The oracle server uses constraints to prevent invalid data entry into tables.We can use constraints to do the following:
Enforce rules on the data in a table whenever a row is inserted, updated, or deleted from that table. The constraint must be satisfied for the operation to succeed.
Prevent the deletion of a table if there are dependencies from other tables.
Provide rules for oracle tools, such as oracle developer.

13. What is a trigger and stored procedure?

Trigger: A named pl/sql block which fires automatically Procedure: A procedure is a subprogram that performs a specific action.