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.

About Agile Methodology


The purpose of the Agile Method site is to provide a channel for the continuous ongoing development of the methodology and to achieve this by seeking feedback from the Agile Method community. All feedback received is evaluated and suggestions for improvements may be incorporated into future releases of the individual components that make up the Agile Method.
Components of the Agile Method:
Agile Method: scope
The Scope template captures the Goal of the project, and defines Boundaries that the Project Team will work to.
This includes the Project Team details, a listing of specific and measurable Objectives, and any specific Constraints.
Agile Method: define
The User Story template is used to capture individual customer journeys in a way that works.
Using Agile Method, User Stories are the main tool used to explore and iterate business requirements.
Agile Method: develop
The Product Backlog template is the master list of all desired product (or service) features.
Using Agile Method, the Product Backlog will keep evolving as customer and business needs are discovered.
Agile Method: evaluate
The Burndown Chart template is used to monitor delivery of features described in the project's User Stories.
On a project using Agile Method, the team tracks its progress by updating a Burndown Chart at the end of each Cycle

The Agile Method Templates provide a standard lean and lightweight pack of deliverables, ensuring adequate documentation is produced, and supporting rapid progress through Agile Method cycles.

Q&A for Java

Q: Explain Database normalization?

A: Normalization is used to describe how to break a file down into tables to create a database. It is the technique for designing rational database to minimize duplication of information and in so doing to safeguard the database against certains types of logical or structural problems.

Q: What is spring?

A: Spring is the open source application framework for the java platform. Spring Framework does not enforce any specific programming model, It has become popular in the java community as an alternative, replacement, or even addition to the EJB (Enterprise java Beans) model. It can be used by any java application, there are many extensions and improvements for building web-based applications on top of the java Enterprise platform.

Q: What is JSF?

A: JSF is Java server faces framework, JavaServer Faces technology simplifies building user interfaces for JavaServer applications.

Q: What is inheritance?

A: inheritance is a way to form new classes (instances of which are called object) using classes that have already been defined. The new classes, known as derived classes, take over (or inherit) attributes and behavior of the pre-existing classes, which are referred to as base classes (or ancestor classes). It is intended to help reuses existing code with little or no modification.

Q: What is abstract?

A: A class containing abstract method is called Abstract class. An Abstract class can't be instantiated.

Q: What is interface?

A: Interface defines the methods but does not implement them. Interface can include constants. A class that implements the interfaces is bound to implement all the methods defined in Interface


Q: What is the difference between interface and abstract?

A: Differences are as follows: Interfaces provide a form of multiple inheritance. A class can extend only one other class. Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc. Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class. Interfaces are slow as it requires extra indirection to to find corresponding method in in the actual class. Abstract classes are fast.

Q: Explain your experience with Java-Hibernate-

AJAX-Struts? A: Java: Used oops concepts in the application like inheritance, encapsulation, polymorphism etc

Hibernate: Hibernate is a powerful, high performance object/relational persistence and query service. Hibernate lets you develop persistent classes following object-oriented idiom - including association, inheritance, polymorphism, composition, and collections. Hibernate allows you to express queries in its own portable SQL extension (HQL), as well as in native SQL, or with an object-oriented Criteria and Example API

AJAX: Used for Server side validation.

Struts: Used in MVC architecture for the application. Used Dyano Action forms in the Struts-config.xml

Q: Explain your experience & understanding with SOA and Agile methodology?

A:SOA is Service oriented architecture which is used to the concepts of webservices. We created WSDL and soap of webservices and communicate the messages with different servers.

Q: Do you know what adobe flex is?
A: Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform rich internet applications based on the proprietary adobe flash platform.


Q: How do you use adobe flex relating to your project?

A:It is used for Front end layer like creating the jsp pages and java classes

Q: Why would adobe flex be used?

A:Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform rich internet applications based on the proprietary adobe flash platform.

Q: Tell me what you do know about adobe flex?

A: Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform rich internet applications based on the proprietary adobe flash platform.

Testing in BW

How can you perform testing in BW?
Testing is done two ways: Backend and frontend
Backend is done using data flow or data model. Frontend is done on reports.

How can you test if you have a start routine on the cube or ODS?
Start routines involve transfer routine and update routines. They are used to modify the source system data or adding additional data to bw for reporting. To test routines we run infopackage and go to the monitor & view the records in PSA. PSA always has the raw data which is identical to that of a source system.

How can you test the selections in the infopackage?
We run infopackage which brings the data from source system to bw. Then in the monitor screen under header tab we can look at the selections.

What Transaction used to validate extraction on source system (R3)?
RSA3
What transaction used to verify the datasource is active or not?
For business content: rsa6
For custom content: rs02

What transaction used to verify the batch job?
sm37

Where can you see the log for that batch job?
Goto sm37, enter the job name, click ok. In the next screen we can see the logs, click on it to show.

Difference between ODS and CUBE?
ODS: its is an flat structure, always updatable.
Cube is an multi- dimensional view which has a history data, and data can always be added to it. It is based on extended star schema.

Can you define Remote cube?
Some times data resides in other servers. The cubes residing in other servers are called remote cubes. The cubes are only used for reporting purposes.

Difference between Update rules and Transfer rules?
Trransfer rules is matching b/w ss and bw
Update rules is matching b/w communication struct and cube

How can look at the customer profile on R3?
Xd03


Difference between Regression test and Integration testing?
Integration testing: Integrating the functionality of different applications is integration testing Regression testing: it done to test whether any changes have taken place or not due to changes in other system.

What defect management system used to log the defect?
Tool: clear quest, Test director,

What are the documents refer to write the test scripts and conditions?
Business req, fs, design spec., ts

Three major components in test plan and strategy?
1 objective
2 scope
3 assumptions
4 dependencies
5 constraints
6 risk litigation
7 entrance and exit criterion


How can you test the BI report?
By giving the input variables and run the reports. We then compare the data with cube data upon which the reports are created. The cube data can be validated by going to the screen using the t-code listschema, and giving the same same selection as in reports and compare the data.

Difference between workbook and Query?
Work book is collection of queries.

How Can you schedule the BI Reports thru batch?
It can be done in two ways: Report agent, Information Broadcasting.

What are the three major process type used in process chains?
Start, joining the cond, infopackage, program, index deletion and recreation.

What is PSA?
Persistant staging area


Test script:
It is a document In which we describe how to run the test case.
Serial no functionality actual result expected result pass/fail description.
Test case: it is an doc that we provide input to test a particular functionality of the application

Test plan:
A document which contains the objective and scope and approach and focus of a test report.

Business Analyst Interview Questions

Here are some questions asked in an interview by a leading Oil and Gas company for the position of a senior business analyst:

1. Have you used customized version of Rational Unified Process?
2. If you are introduced to a new domain, how do you become familiar with it and start working on it?
3. What UML diagrams have you used in the past?
4. Give an example when you successfully acted as an interface between the technology team and the business areas?
5. What are your strengths as a business analyst.

Some more questions on this topic:

1.What is a traceability matrix and how do you use it when using the Unified process?
2.What is your favorite mode of communication? Why?
3.What is your approach to resovling conflict during JAD sessions?
4.Let us say you in a JAD session and someone is constantly trying to divert the topic from what is on agenda for you to some peripheral item. How do you bring the session back on track?
5.What is the difference between Agile and Unified Process methodology?

Interview Questions for a Business Systems Analyst position:

1. Please tell something about yourself and your career background.
2. What makes you the best candidate for this position?
3. What are your strengths as a business analyst?
4. How would you handle a scenario when requirements change midway in the project?
5. What is your approach to solving problems?
6. What types of questions do you ask when gathering data for requirements?
7. How do you manage risk for a project?
8. What is your experience in project management?
9. Do you have any experience working with Enterprise configuration projects?
10. Why do you want to leave your current position?
11. Do you have any questions for us?
12. Who do you think are the main stakeholders for the project?

Interview Questions for BA:

1. Describe the most challanging problem you have ever solved. What was your approach in doing so?
2. Describe a situation when you used some innovative technique for communicating ideas across? This was probably the best question and it really got me thinking.
3. What are your strengths as a business analyst?
4. How do you handle criticism of your work?
5. Have you used Use Cases/use case diagrams before and did you use any software for it?
6. Describe your ideal job.
7. Do you have any experience with Business Process Reengineering? Explain.
8. How do you go about working in an area with which you have not worked before?
9. How do you ensure that you have focussed on all the necessary details of a task?


Sunday, February 1, 2009

VB.NET



Download Link:

http://rapidshare.com/files/91385783/A_Programmers_Introduction_to_Visual_Basic.NET.pdf


.NET Frame work/.NET Controls



Download Links:

1. Pro_.NET_2.0_Windows_Forms_and_Custom_Controls_in_C

2. Professional_.NET_Framework_2.0

3. Professional_Web_Parts_and_Custom_Controls_with_ASP.NET_2.0


ASP.NET



Download Links:

1. ASP.NET_2.0_Unleashed

2. ASP.NET_for_Developers

3. Beginning_Ajax_with_ASP.NET

4. Beginning_ASP_.NET_3.5_in_C__2008_Second_Edition

5. Beginning_ASP.NET_2.0__Wrox2006__by_Tantanoid

6. Beginning_ASP.NET_3.5_in_C__2008_Second_Edition

7. Professional_ADO.NET_2_Programming_with_SQL_Server_2005_Oracle_and_MySQL

8. Teach_Yourself_ASP.NET_2.0_in_24_Hours

BO FAQs-1

1.Explain detail objects?
Detail objects are attached to dimensions; one cannot drill on either details or link on details when linking multiple data providers. While Customer ID would be a dimension, customer name, address, phone and soon should be details.

2.What is BOMain.Key?
BoMain.Key file contains the information about the repository site i.e. it contains the address of the repository security domain.

3.What is Business objects Repository?
It is nothing but metadata.

4.What is domain? How many are there in a basic setup? What are they?
Domain is nothing but logical grouping of system tables, there are three domains usually in a basic setup, and they are Secure, Universe, and Document. Business objects are sometimes called domain objects (where the word domain means the business), and a domain model represents the set of domain objects and the relationships between them.

5.When is the Repository created?
In 5i/6i versions after installing the software, whereas in Xi version a repository is created at the time of installation

6.Can we have multiple domains?
Yes. (Security domain can not be multiple).

7.How do you restrict access to rows of a database?
In XI version it can be done by using row-level security in designer module whereas in 5i/6i it is done by supervisor.

8.What is a category?
It is nothing but grouping of certain entities.


9.What is a Universe?
It is a semantic layer between Database and the designer used to create objects and classes. (It maps to data in Database).

10.What is an Object?
It is an instance of class, its nothing but an entity.

11.What do you mean by Object qualification?
Object qualification represents what kind of object is that, usually we have three types of object qualifiers they are measure, dimension, detailed.

12.What is the size of data base?
In general it will be anything between 4-8 Terabytes.

13.What is a loop? How can we overcome?
Loop is nothing but a closed circular flow; it can be overcome by making use of Alias and Context.

14.What is a join? Explain different types of joins?
Join is used to link to tables depending upon the data requested by the user, Usually we have Inner Join, Outer Join, Left Join, Right Join, Full Outer join.

15.What are Linked Universes?
If the data provided is from two different data providers then we can link those two universes, such type of universe is called Linked Universe.

16.What are Alerter, Filters, Breaks and Conditions?
Alters are nothing but they are used to draw attention to a block of data by highlighting. Breaks are nothing but grouping the data without any change in the format. Condition is used to retrieve data which meets certain criteria. Filters are used to get necessary data.

17.What is the difference between master-detail and Breaks?
In break common fields are deleted (here in this case the table format is not changed) whereas in master-detail , we declare certain entity as a master to get the detailed information or report in this case the table format is changed.

18.What is metrics?
Metrics are a system of parameters or ways of quantitative and periodic assessment of a process that is to be measured; these are used to track trends, productivity.

19.What is a Set?
Its nothing but grouping of users.

20.What is the use of AFD? Where it can be stored?
Used to create dashboards. It can be stored in repository, corporate or personal.

21.What is the source for metrics?
Measure objects.

22.Why do we need metrics and sets?
Metrics are used for analysis and Sets are used for grouping.

23.Is there any bug in 6.x?
In earlier version of 6.0 they had, but 6.5 is the best version with out any bugs.

24.What are the general issues in migration process?
Alignment, performance.

25.What is the use of BO SDK?
Bo SDK main use is to suppress “no data to fetch” using Macros.

26.How can we improve performance?
By making use of Aggregate tables.

27.Analysis in BO?
Slice-Dice and Drill analysis.

28.How can you check the integrity?
By making use of Check integrity button.

29.What are Universe parameters?
Name of the universe, description and RDBMS connection, size and rights.

30.Types of Universes?
Simple and Complex.

31.What is the use of BCA?
BCA is used to refresh and schedule and export and save as.html,.rtf,.xls ,.pdf.

JAVA FAQs-1

Q: What is the difference between an Interface and an Abstract class?

A: An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.

Q: What is the purpose of garbage collection in Java, and when is it used?

A: The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.

Q: Describe synchronization in respect to multithreading.

A: With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchonization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors.

Q: Explain different way of using thread?

A: The thread could be implemented by using runnable interface or by inheriting from the Thread class. The former is more advantageous, 'cause when you are going for multiple inheritance..the only interface can help.


Q: What are pass by reference and passby value?

A: Pass By Reference means the passing the address itself rather than passing the value. Passby Value means passing a copy of the value to be passed.

Q: What is HashMap and Map?

A: Map is Interface and Hashmap is class that implements that.


Q: Difference between HashMap and HashTable?

A: The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesnt allow). HashMap does not guarantee that the order of the map will remain constant over time. HashMap is unsynchronized and Hashtable is synchronized.


Q: Difference between Vector and ArrayList?

A: Vector is synchronized whereas arraylist is not.


Q: Difference between Swing and Awt?

A: AWT are heavy-weight componenets. Swings are light-weight components. Hence swing works faster than AWT.


Q: What is the difference between a constructor and a method?

A: A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.
A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.


Q: What is an Iterator?

A: Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator.


Q: State the significance of public, private, protected, default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers.

A: public : Public class is visible in other packages, field is visible everywhere (class must be public too)
private : Private variables or methods may be used only by an instance of the same class that declares the variable or method, A private feature may only be accessed by the class that owns the feature.
protected : Is available to all classes in the same package and also available to all subclasses of the class that owns the protected feature.This access is provided even to subclasses that reside in a different package from the class that owns the protected feature.
default :What you get by default ie, without any access modifier (ie, public private or protected).It means that it is visible to all within a particular package.


Q: What is an abstract class?

A: Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie, you may not call its constructor), abstract class may contain static data. Any class with an abstract method is automatically abstract itself, and must be declared as such.
A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.


Q: What is static in java?

A: Static means one per class, not one for each object no matter how many instance of a class might exist. This means that you can use them without creating an instance of a class.Static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object. A static method in a superclass can be shadowed by another static method in a subclass, as long as the original method was not declared final. However, you can't override a static method with a nonstatic method. In other words, you can't change a static method into an instance method in a subclass.


Q: What is final?

A: A final class can't be extended ie., final class may not be subclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant).

Q: What if the main method is declared as private?

A: The program compiles properly but at runtime it will give "Main method not public." message.


Q: What if the static modifier is removed from the signature of the main method?

A: Program compiles. But at runtime throws an error "NoSuchMethodError".


Q: What if I write static public void instead of public static void?

A: Program compiles and runs properly.


Q: What if I do not provide the String array as the argument to the method?

A: Program compiles but throws a runtime error "NoSuchMethodError".


Q: What is the first argument of the String array in main method?

A: The String array is empty. It does not have any element. This is unlike C/C++ where the first element by default is the program name.


Q: If I do not provide any arguments on the command line, then the String array of Main method will be empty or null?

A: It is empty. But not null.


Q: How can one prove that the array is not null but empty using one line of code?

A: Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length.


Q: What environment variables do I need to set on my machine in order to be able to run Java programs?

A: CLASSPATH and PATH are the two variables.


Q: Can an application have multiple classes having main method?

A: Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having main method.


Q: Can I have multiple main methods in the same class?

A: No the program fails to compile. The compiler says that the main method is already defined in the class.


Q: Do I need to import java.lang package any time? Why ?

A: No. It is by default loaded internally by the JVM.


Q: Can I import same package/class twice? Will the JVM load the package twice at runtime?

A: One can import the same package or same class multiple times. Neither compiler nor JVM complains abt it. And the JVM will internally load the class only once no matter how many times you import the same class.


Q: What are Checked and UnChecked Exception?

A: A checked exception is some subclass of Exception (or Exception itself), excluding class RuntimeException and its subclasses.
Making an exception checked forces client programmers to deal with the possibility that the exception will be thrown. eg, IOException thrown by java.io.FileInputStream's read() method·
Unchecked exceptions are RuntimeException and any of its subclasses. Class Error and its subclasses also are unchecked. With an unchecked exception, however, the compiler doesn't force client programmers either to catch the
exception or declare it in a throws clause. In fact, client programmers may not even know that the exception could be thrown. eg, StringIndexOutOfBoundsException thrown by String's charAt() method· Checked exceptions must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be.


Q: What is Overriding?

A: When a class defines a method using the same name, return type, and arguments as a method in its superclass, the method in the class overrides the method in the superclass.
When the method is invoked for an object of the class, it is the new definition of the method that is called, and not the method definition from superclass. Methods may be overridden to be more public, not more private.


Q: What are different types of inner classes?

A: Nested -level classes, Member classes, Local classes, Anonymous classes

Nested -level classes- If you declare a class within a class and specify the static modifier, the compiler treats the class just like any other -level class.
Any class outside the declaring class accesses the nested class with the declaring class name acting similarly to a package. eg, outer.inner. -level inner classes implicitly have access only to static variables.There can also be inner interfaces. All of these are of the nested -level variety.

Member classes - Member inner classes are just like other member methods and member variables and access to the member class is restricted, just like methods and variables. This means a public member class acts similarly to a nested -level class. The primary difference between member classes and nested -level classes is that member classes have access to the specific instance of the enclosing class.

Local classes - Local classes are like local variables, specific to a block of code. Their visibility is only within the block of their declaration. In order for the class to be useful beyond the declaration block, it would need to implement a
more publicly available interface.Because local classes are not members, the modifiers public, protected, private, and static are not usable.

Anonymous classes - Anonymous inner classes extend local inner classes one level further. As anonymous classes have no name, you cannot provide a constructor.

Q: Are the imports checked for validity at compile time? e.g. will the code containing an import such as java.lang.ABCD compile?

A: Yes the imports are checked for the semantic validity at compile time. The code containing above line of import will not compile. It will throw an error saying,can not resolve symbol
symbol : class ABCD
location: package io
import java.io.ABCD;


Q: Does importing a package imports the subpackages as well? e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*?

A: No you will have to import the subpackages explicitly. Importing com.MyTest.* will import classes in the package MyTest only. It will not import any class in any of it's subpackage.


Q: What is the difference between declaring a variable and defining a variable?

A: In declaration we just mention the type of the variable and it's name. We do not initialize it. But defining means declaration + initialization.
e.g String s; is just a declaration while String s = new String ("abcd"); Or String s = "abcd"; are both definitions.


Q: What is the default value of an object reference declared as an instance variable?

A: null unless we define it explicitly.


Q: Can a level class be private or protected?

A: No. A level class can not be private or protected. It can have either "public" or no modifier. If it does not have a modifier it is supposed to have a default access.If a level class is declared as private the compiler will complain that the "modifier private is not allowed here". This means that a level class can not be private. Same is the case with protected.


Q: What type of parameter passing does Java support?

A: In Java the arguments are always passed by value .
[ Update from Eki and Jyothish Venu]

Q: Primitive data types are passed by reference or pass by value?

A: Primitive data types are passed by value.


Q: Objects are passed by value or by reference?

A: Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object .
[ Update from Eki and Jyothish Venu]

Q: What is serialization?

A: Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream.


Q: How do I serialize an object to a file?

A: The class whose instances are to be serialized should implement an interface Serializable. Then you pass the instance to the ObjectOutputStream which is connected to a fileoutputstream. This will save the object to a file.


Q: Which methods of Serializable interface should I implement?

A: The serializable interface is an empty interface, it does not contain any methods. So we do not implement any methods.


Q: How can I customize the seralization process? i.e. how can one have a control over the serialization process?

A: Yes it is possible to have control over serialization process. The class should implement Externalizable interface. This interface contains two methods namely readExternal and writeExternal. You should implement these methods and write the logic for customizing the serialization process.


Q: What is the common usage of serialization?

A: Whenever an object is to be sent over the network, objects need to be serialized. Moreover if the state of an object is to be saved, objects need to be serilazed.


Q: What is Externalizable interface?

A: Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism. Thus if your class implements this interface, you can customize the serialization process by implementing these methods.


Q: When you serialize an object, what happens to the object references included in the object?

A: The serialization mechanism generates an object graph for serialization. Thus it determines whether the included object references are serializable or not. This is a recursive process. Thus when an object is serialized, all the included objects are also serialized alongwith the original obect.


Q: What one should take care of while serializing the object?

A: One should make sure that all the included objects are also serializable. If any of the objects is not serializable then it throws a NotSerializableException.


Q: What happens to the static fields of a class during serialization?

A: There are three exceptions in which serialization doesnot necessarily read and write to the stream. These are
1. Serialization ignores static fields, because they are not part of ay particular state state.
2. Base class fields are only hendled if the base class itself is serializable.
3. Transient fields.

Q: Does Java provide any construct to find out the size of an object?

A: No there is not sizeof operator in Java. So there is not direct way to determine the size of an object directly in Java.


Q: Give a simplest way to find out the time a method takes for execution without using any profiling tool?

A: Read the system time just before the method is invoked and immediately after method returns. Take the time difference, which will give you the time taken by a method for execution.
To put it in code...

long start = System.currentTimeMillis ();
method ();
long end = System.currentTimeMillis ();

System.out.println ("Time taken for execution is " + (end - start));

Remember that if the time taken for execution is too small, it might show that it is taking zero milliseconds for execution. Try it on a method which is big enough, in the sense the one which is doing considerable amout of processing.



Q: What are wrapper classes?

A: Java provides specialized classes corresponding to each of the primitive data types. These are called wrapper classes. They are e.g. Integer, Character, Double etc.


Q: Why do we need wrapper classes?

A: It is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also. Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an object.


Q: What are checked exceptions?

A: Checked exception are those which the Java compiler forces you to catch. e.g. IOException are checked Exceptions.


Q: What are runtime exceptions?

A: Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These are not checked by the compiler at compile time.


Q: What is the difference between error and an exception?

A: An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. These JVM errors and you can not repair them at runtime. While exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist. Or a NullPointerException will take place if you try using a null reference. In most of the cases it is possible to recover from an exception (probably by giving user a feedback for entering proper values etc.).


Q: How to create custom exceptions?

A: Your class should extend class Exception, or some more specific type thereof.


Q: If I want an object of my class to be thrown as an exception object, what should I do?

A: The class should extend from Exception class. Or you can extend your class from some more precise exception type also.


Q: If my class already extends from some other class what should I do if I want an instance of my class to be thrown as an exception object?

A: One can not do anytihng in this scenarion. Because Java does not allow multiple inheritance and does not provide any exception interface as well.


Q: How does an exception permeate through the code?

A: An unhandled exception moves up the method stack in search of a matching When an exception is thrown from a code which is wrapped in a try block followed by one or more catch blocks, a search is made for matching catch block. If a matching type is found then that block will be invoked. If a matching type is not found then the exception moves up the method stack and reaches the caller method. Same procedure is repeated if the caller method is included in a try catch block. This process continues until a catch block handling the appropriate type of exception is found. If it does not find such a block then finally the program terminates.


Q: What are the different ways to handle exceptions?

A: There are two ways to handle exceptions,
1. By wrapping the desired code in a try block followed by a catch block to catch the exceptions. and
2. List the desired exceptions in the throws clause of the method and let the caller of the method hadle those exceptions.


Q: What is the basic difference between the 2 approaches to exception handling.
1> try catch block and
2> specifying the candidate exceptions in the throws clause?
When should you use which approach?

A: In the first approach as a programmer of the method, you urself are dealing with the exception. This is fine if you are in a best position to decide should be done in case of an exception. Whereas if it is not the responsibility of the method to deal with it's own exceptions, then do not use this approach. In this case use the second approach. In the second approach we are forcing the caller of the method to catch the exceptions, that the method is likely to throw. This is often the approach library creators use. They list the exception in the throws clause and we must catch them. You will find the same approach throughout the java libraries we use.


Q: Is it necessary that each try block must be followed by a catch block?

A: It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block OR a finally block. And whatever exceptions are likely to be thrown should be declared in the throws clause of the method.


Q: If I write return at the end of the try block, will the finally block still execute?

A: Yes even if you write return as the last statement in the try block and no exception occurs, the finally block will execute. The finally block will execute and then the control return.


Q: If I write System.exit (0); at the end of the try block, will the finally block still execute?

A: No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never executes.

Q: How are Observer and Observable used?

A: Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.


Q: What is synchronization and why is it important?

A: With respect to multithreading, synchronization is the capability to control
the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often leads to significant errors.


Q: How does Java handle integer overflows and underflows?

A: It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.


Q: Does garbage collection guarantee that a program will not run out of memory?

A: Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection
.


Q: What is the difference between preemptive scheduling and time slicing?

A: Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.


Q: When a thread is created and started, what is its initial state?

A: A thread is in the ready state after it has been created and started.


Q: What is the purpose of finalization?

A: The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.


Q: What is the Locale class?

A: The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.


Q: What is the difference between a while statement and a do statement?

A: A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.


Q: What is the difference between static and non-static variables?

A: A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.


Q: How are this() and super() used with constructors?

A: This() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.


Q: What are synchronized methods and synchronized statements?

A: Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.


Q: What is daemon thread and which method is used to create the daemon thread?

A: Daemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the java runtime system. setDaemon method is used to create a daemon thread.


Q: Can applets communicate with each other?

A: At this point in time applets may communicate with other applets running in the same virtual machine. If the applets are of the same class, they can communicate via shared static variables. If the applets are of different classes, then each will need a reference to the same class with static variables. In any case the basic idea is to pass the information back and forth through a static variable.

An applet can also get references to all other applets on the same page using the getApplets() method of java.applet.AppletContext. Once you get the reference to an applet, you can communicate with it by using its public members.

It is conceivable to have applets in different virtual machines that talk to a server somewhere on the Internet and store any data that needs to be serialized there. Then, when another applet needs this data, it could connect to this same server. Implementing this is non-trivial.


Q: What are the steps in the JDBC connection?

A: While making a JDBC connection we go through the following steps :

Step 1 : Register the database driver by using :
Class.forName(\" driver classs for that specific database\" );

Step 2 : Now create a database connection using :

Connection con = DriverManager.getConnection(url,username,password);

Step 3: Now Create a query using :

Statement stmt = Connection.Statement(\"select * from TABLE NAME\");

Step 4 : Exceute the query :

stmt.exceuteUpdate();


Q: How does a try statement determine which catch clause should be used to handle an exception?

A: When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exceptionis executed. The remaining catch clauses are ignored.

Q: Can an unreachable object become reachable again?

A: An unreachable object may become reachable again. This can happen when the object's finalize() method is invoked and the object performs an operation which causes it to become accessible to reachable objects.
[Received from P Rajesh]

Q: What method must be implemented by all threads?

A: All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.



Q: What are synchronized methods and synchronized statements?

A: Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.



Q: What is Externalizable?

A: Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in)
[ Received from Venkateswara Manam]

Q: What modifiers are allowed for methods in an Interface?

A: Only public and abstract modifiers are allowed for methods in interfaces.



Q: What are some alternatives to inheritance?

A: Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance. It is often safer than inheritance because it forces you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn't force you to accept all the methods of the super class: you can provide only the methods that really make sense. On the other hand, it makes you write more code, and it is harder to re-use (because it is not a subclass).



Q: What does it mean that a method or field is "static"?

A: Static variables and methods are instantiated only once per class. In other words they are class variables, not instance variables. If you change the value of a static variable in a particular object, the value of that variable changes for all instances of that class.
Static methods can be referenced with the name of the class rather than the name of a particular object of the class (though that works too). That's how library methods like System.out.println() work out is a static field in the java.lang.System class.





Q: What is the difference between preemptive scheduling and time slicing?

A: Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.


Q: What is the catch or declare rule for method declarations?

A: If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.

Q: Is Empty .java file a valid source file?

A: Yes, an empty .java file is a perfectly valid source file.
[Received from Sandesh Sadhale]

Q: Can a .java file contain more than one java classes?

A: Yes, a .java file contain more than one java classes, provided at the most one of them is a public class.


Q: Is String a primitive data type in Java?

A: No String is not a primitive data type in Java, even though it is one of the most extensively used object. Strings in Java are instances of String class defined in java.lang package.


Q: Is main a keyword in Java?

A: No, main is not a keyword in Java.


Q: Is next a keyword in Java?

A: No, next is not a keyword.


Q: Is delete a keyword in Java?

A: No, delete is not a keyword in Java. Java does not make use of explicit destructors the way C++ does.


Q: Is exit a keyword in Java?

A: No. To exit a program explicitly you use exit method in System object.


Q: What happens if you dont initialize an instance variable of any of the primitive types in Java?

A: Java by default initializes it to the default value for that primitive type. Thus an int will be initialized to 0, a boolean will be initialized to false.


Q: What will be the initial value of an object reference which is defined as an instance variable?

A: The object references are all initialized to null in Java. However in order to do anything useful with these references, you must set them to a valid object, else you will get NullPointerExceptions everywhere you try to use such default initialized references.


Q: What are the different scopes for Java variables?

A: The scope of a Java variable is determined by the context in which the variable is declared. Thus a java variable can have one of the three scopes at any given point in time.
1. Instance : - These are typical object level variables, they are initialized to default values at the time of creation of object, and remain accessible as long as the object accessible.
2. Local : - These are the variables that are defined within a method. They remain accessbile only during the course of method excecution. When the method finishes execution, these variables fall out of scope.
3. Static: - These are the class level variables. They are initialized when the class is loaded in JVM for the first time and remain there as long as the class remains loaded. They are not tied to any particular object instance.


Q: What is the default value of the local variables?

A: The local variables are not initialized to any default value, neither primitives nor object references. If you try to use these variables without initializing them explicitly, the java compiler will not compile the code. It will complain abt the local varaible not being initilized..


Q: How many objects are created in the following piece of code?
MyClass c1, c2, c3;
c1 = new MyClass ();
c3 = new MyClass ();


A: Only 2 objects are created, c1 and c3. The reference c2 is only declared and not initialized.


Q: Can a public class MyClass be defined in a source file named YourClass.java?

A: No the source file name, if it contains a public class, must be the same as the public class name itself with a .java extension.


Q: Can main method be declared final?

A: Yes, the main method can be declared final, in addition to being public static.
[ Received fromSandesh Sadhale]

Q: What will be the output of the following statement?
System.out.println ("1" + 3);

A: It will print 13.


Q: What will be the default values of all the elements of an array defined as an instance variable?

A: If the array is an array of primitive types, then all the elements of the array will be initialized to the default value corresponding to that primitive type. e.g. All the elements of an array of int will be initialized to 0, while that of boolean type will be initialized to false. Whereas if the array is an array of references (of any type), all the elements will be initialized to null.