Skip to main content

Posts

Showing posts from May, 2010

XML Binding with JAXB 2.0 - Tutorial

Java Architecture for XML Binding (JAXB) is an API/framework that binds XML schema to Java representations. Java objects may then subsequently be used to marshal or unmarshal XML documents. Marshalling an XML document means creating an XML document from Java objects. Unmarshalling means creating creating a Java representation of an XML document (or, in effect, the reverse of marshaling). You retrieve the element and attribute values of the XML document from the Java representation. The JAXB 2.0 specification is implemented in JWSDP 2.0. JAXB 2.0 has some new features, which facilitate the marshalling and unmarshalling of an XML document. JAXB 2.0 also allows you to map a Java object to an XML document or an XML Schema. Some of the new features in JAXB 2.0 include: Smaller runtime libraries are required for JAXB 2.0, which require lesser runtime memory. Significantly, fewer Java classes are generated from a schema, compared to JAXB 1.0. For each top-level complexType, 2.0 generates a v...

How to Succeed in Java/J2ee Interviews...

Are technical skills alone or just being a quiet achiever sufficient to boost your career? The answer is no. The technical, analytical and problem solving skills must be complemented with: Effective marketing skills to promote your skills, knowledge, and achievements along with ability to negotiate your promotions, salary or contract rates. Now days it is a rarity for management to pro-actively recognize or reward their staff unless there is an immediate vacancy to fill. If you cannot determine your net worth, how the management can? Effective communication, interpersonal, presentation, mentoring, being a team player and business skills. I have seen candidates with technical, analytical and/or problem solving brilliance getting either sacked or failing to make a mark in their careers due to lack of one or more of the above mentioned skills. There are myriad of books and online articles that can help you on the second bullet point, so let me elaborate on the first bullet point bas...

Java Interview Questions

What is the difference between JTS and JTA? In any J2EE application transaction management is one of the most crucial requirements of the application. Given the complexity of today's business requirements, transaction processing occupies one of the most complex segments of enterprise level distributed applications to build, deploy and maintain. JTS specifies the implementation of a Java transaction manager. JTS specifies the implementation of a Transaction Manager which supports the Java Transaction API (JTA) 1.0 This transaction manager supports the JTA, using which application servers can be built to support transactional Java applications. Internally the JTS implements the Java mapping of the OMG OTS 1.1 specifications. The Java mapping is specified in two packages: org.omg.CosTransactions and org.omg.CosTSPortability. The JTS thus provides a new architecture for transactional application servers and applications, while complying to the OMG OTS 1.1 interfaces internally. This al...

Java Classes and Objects Interview Qns

What restrictions are placed on method overloading? Two methods may not have the same name and argument list but different return types. What is the difference between String and StringBuffer? String objects are immutable whereas StringBuffer objects are not. StringBuffer unlike Strings support growable and modifiable strings. Can a private method of a superclass be declared within a subclass? Sure. A private field or method or inner class belongs to its declared class and hides from its subclasses. There is no way for private stuff to have a runtime overloading or overriding (polymorphism) features. What is the default value of an object reference declared as an instance variable? null unless we define it explicitly. What is the difference between a constructor and a method? Or How can a subclass call a method or a constructor defined in a superclass? A constructor is a member function of a class that is used to create objects of that class, invoked using the new operato...

How to succeed in Interviews??

Question 1 Tell me about yourself. TRAPS : Beware, about 80% of all interviews begin with this “innocent” question. Many candidates, unprepared for the question, skewer themselves by rambling, recapping their life story, delving into ancient work history or personal matters. BEST ANSWER: Start with the present and tell why you are well qualified for the position. Remember that the key to all successful interviewing is to match your qualifications to what the interviewer is looking for. In other words you must sell what the buyer is buying. This is the single most important strategy in job hunting. So, before you answer this or any question it's imperative that you try to uncover your interviewer's greatest need, want, problem or goal. To do so, make you take these two steps: 1. Do all the homework you can before the interview to uncover this person's wants and needs (not the generalized needs of the industry or company) 2. As early as you can in the interview,...

What is the difference between JTS and JTA?

In any J2EE application transaction management is one of the most crucial requirements of the application. Given the complexity of today's business requirements, transaction processing occupies one of the most complex segments of enterprise level distributed applications to build, deploy and maintain. JTS specifies the implementation of a Java transaction manager. JTS specifies the implementation of a Transaction Manager which supports the Java Transaction API (JTA) 1.0 This transaction manager supports the JTA, using which application servers can be built to support transactional Java applications. Internally the JTS implements the Java mapping of the OMG OTS 1.1 specifications. The Java mapping is specified in two packages: org.omg.CosTransactions and org.omg.CosTSPortability. The JTS thus provides a new architecture for transactional application servers and applications, while complying to the OMG OTS 1.1 interfaces internally. This allows the JTA compliant applications to inte...

Java Garbage Collection

Explain Garbage collection mechanism in Java? Garbage collection is one of the most important features of Java. 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. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use. In Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected. Garbage collection is an automatic pro...

JVM ( Java Virtual Machine )

1.What is JVM? A Java Virtual Machine is a runtime environment required for execution of a Java application.Every Java application runs inside a runtime instance of some concrete implementation of abstract specifications of JVM.It is JVM which is crux of 'platform independent' nature of the language. 2.What is a JVM consisted of? Each time a Java Application is executed then an instance of JVM ,responsible for its running,is created.A JVM instance is described in terms of subsystems, memory areas, data types, and instructions.The block diagram given below,depicts a view of Internal Architecture of JVM : 3.What is a class loader and what is its responsibilities? The Class loader is a subsystem of a JVM which is responsible,predominantly for loading classes and interfaces in the system.Apart from this,a class loader is responsible for the following activities:-Verification of imported types(classes and interfaces)-Allocating memory for class variables and initializing them...

Master List of Java J2ee Interview Questions

if you prepare the answers for the questions below, it's not a tough job to get job of Software Engineer in Java J2ee Technologies. Then why are delaying let tune your mind to get answers. Search this blog you will get answers here itself. Wish You Good Luck for interviews... 1. What is Entity Bean and Session Bean ? 2. What are the methods of Entity Bean? 3. How does Stateful Session bean store its state ? 4. Why does Stateless Session bean not store its stateeven though it has ejbActivate and ejbPassivate ? 5. What are the services provided by the container ? 6. Types of transaction ? 7. What is bean managed transaction ? 8. Why does EJB needs two interface( Home and Remote Interface) ? 9. What are transaction attributes ?

Object Serialization

How many methods in the Serializable interface? Which methods of Serializable interface should I implement? There is no method in the Serializable interface. It’s an empty interface which does not contain any methods. The Serializable interface acts as a marker, telling the object serialization tools that the class is serializable. So we do not implement any methods. What is the difference between Serializalble and Externalizable interface? How can you control over the serialization process i.e. how can you customize the seralization process? When you use Serializable interface, your class is serialized automatically by default. But you can override writeObject() and readObject() two methods to control more complex object serailization process. When you use Externalizable interface, you have a complete control over your class's serialization process. This interface contains two methods namely readExternal and writeExternal. You should implement these methods and write the logi...

JMS (JAVA MESSAGING SERVICE)

1. What is JMS ? A. JMS (JAVA MESSAGING SERVICE) is an API .It is a specification with one package javax.jms .It is a technology which can pass the information synchronously or asynchronously . 2. On what technology is JMS based ? A. JMS is based on Message-Oriented MiddleWare (MOM). 3. What was the technology for messaging services before JMS was released? A. Before JMS API specification was released by javasoft ,there was IBM’s MQSeries implementation of MOM (Message-Oriented MiddleWare). 4. What is MOM (Message-Oriented MiddleWare) ? A. MOM is a software infrastructure that asynchronously connects multiple system’s through the production and consumption of data message. 5. How many types of data passing does JMS specification allows ?What are they? A. JMS specification allows two types of data passing. a)publish/subscribe [pub/sub model] b)point-to-point [p-t-p model] 6. In real time which type of data passing is used ? A. Mostly in real time applications we use both type...

Files, Streams, I/O (Java.io)

Deleting a Directory (new File("directoryName")).delete(); Creating a Temporary File try { // Create temp file. File temp = File.createTempFile( "pattern", ".suffix"); // Delete temp file when program exits . temp.deleteOnExit(); // Write to temp file BufferedWriter out = new BufferedWriter( new FileWriter(temp)); out.write("aString"); out.close(); } catch (IOException e) { } Using a Random Access File try { File f = new File("filename"); RandomAccessFile raf = new RandomAccessFile(f, "rw"); // Read a character. char ch = raf.readChar(); // Seek to end of file. raf.seek(f.length()); // Append to the end. raf.writeChars("aString"); raf.close(); } catch (IOException e) { } Serializing an Object The object to be serialized must implement java.io.Serializable. try { ObjectOutput out = new ObjectOutputStream( new FileOutputStream("filename.ser")); out.writeObject(...

How to develop,test and maintain SOA based solutions?

As I have discussed earlier, analysis and design part of SOA centers around three approaches SOAD,SOMA and BDD.If you want to recap these concepts then read my blog 'Constituents of SOA'. In this post, my focus will be to develop SOA using web services.I will talk about webservices in its underlying technologies and in next post, how Apache Axis works to create web services over SOAP and several tools to test webservices.I will take a step-by-step approach for creating one simple web service using Apache Axis meant for Java. Apache Axis also supports C++.The web service example mentioned in this blog requires fair knowledge of Java for its audiences to put this knowledge into practise.

What is a Service in an SOA?

A Service in an SOA meets the following criteria: ·                             Multiple-use ·                             Non-context-specific ·                             Composable with other components ·                             Encapsulated i.e., non-investigable through its interfaces ·                          ...

Who suits for SOA?

The IT infrastructure which includes various business critical systems of an enterprise are built over a long period of time.They cannot always be made with latest technologies as their is already investment being made in earlier systems.The organizations which breathe change like oxygen have to think new ways in order to integrate all its existing systems,new or legacy, in order to orchestrate its business process with its partners,suppliers and customers.The IT strategies of organizations change with mergers and acquisitions and leads to more vendor or application specific systems, sometimes repeat of an application by different vendor, in such a scenario whole IT landscape of an organization becomes quite complex.

Why we need SOA?

With advent of IT revolution, it is information that people want and technology is a mean to supply it and with time it is provided at lower costs.So keeping the costs continuously low is a challenge.These days business houses have huge dependency on IT and it cannot be wiped out completely.It makes great business sense to save costs that incur on big investments that these organizations do on IT infrastructure for running their complex business processes. The existing systems in an organization are rarely thrown away and they are valuable asset for enterprise from business point of view.SOA leverages the benefits of integrating new systems with old legacy ones.It is instrumental in linking IT resources and put them to reuse.The cost effectiveness of this style of architecture focuses on services rather on objects.The similar concepts have always been around like Java Connector Architecture propounds the same concepts so SOA is a kind of evolution of existing set of knowledge mainly...

Free Scripting / Utility Tools

You can find at below link number of scripting/utility tools used in software development or production environments. Like Batch Fiel Utilities, Windows Resource Kits, Script Compilers & Packagers, Scripting Editors & IDEs, Code Generators, Regular expression tools, Automation Tools, VBScript Add-ons, Printing Tools, Inventory Tools, Shell Extensions, File Viewers & Converters, Backup Utilities, Security Tools, etc., Many of them are free and for the rest you need t buy with nominal charges. Really this site is useful. Check it out. This site much useful content.   Scripting Tools

What is SOA?

SOA has become a de-facto standard for system development and integration of new with existing legacy solutions running and supporting complex business processes. SOA, as IT world has always a fancy term for any new technology,elaborates to Serivce Oriented Architecture, is not a new term and has been around with emergence of webservices. In order to understand SOA, we must first understand what a   webservice   means, which is sometimes referred as crux of SOA,not always though.A system does not necessarily need to use web services and all related standards to be "service-oriented." For example, some service oriented systems have been implemented using Corba,DCOM,RPC, Jini and REST.A webservice is defined by a set of processes over a network which is a manifestation of some physical entities like databases,devices,programs.

Why would you prefer code reuse via composition over inheritance?

  Both the approaches make use of polymorphism and gives code reuse (in different ways) to achieve the same results but: The advantage of class inheritance is that it is done statically at compile-time and is easy to use. The disadvantage of class inheritance is that because it is static, implementation inherited from a parent class cannot be changed at run  time. In object composition, functionality is acquired dynamically at run-time by objects collecting references to other objects. The advantage of this approach is that implementations can be replaced at run-time. This is possible because objects are accessed only through their interfaces, so one object can be replaced with another just as long as they have the same type. For example: the composed class AccountHelperImpl can be replaced by another more efficient implementation as shown below if required:

Java Health Center - Overview and Features

This video highlights the features available in Health Center. Health Center is a low-processor and memory usage diagnostic tool for monitoring the status of a running IBM Java Virtual Machine (JVM). Health Center provides live information and recommendations in each of the following areas: - Classes: information about classes being loaded - Environment: details of the configuration and system of the monitored application - Garbage Collection: information about the Java heap and pause times - Locking: information about contention on inflated locks - Profiling: sampling profile of Java methods including call paths

Install IBM Support Assistant and Java Health Center

This video guide takes you through the necessary steps to install and launch Health Center from the IBM Support Assistant. Health Center is a low-processor and memory usage diagnostic tool for monitoring the status of a running IBM Java Virtual Machine (JVM). Health Center provides live information and recommendations in each of the following areas: * Classes: information about classes being loaded * Environment: details of the configuration and system of the monitored application * Garbage Collection: information about the Java heap and pause times * Locking: information about contention on inflated locks * Profiling: sampling profile of Java methods including call paths.

Enable a Java application for live monitoring by the Health Centre

This video guide takes you through the necessary steps to enable a Java application for live monitoring by the Health Center. Health Center is a low-processor and memory usage diagnostic tool for monitoring the status of a running IBM Java Virtual Machine (JVM). Health Center provides live information and recommendations in each of the following areas: * Classes: information about classes being loaded * Environment: details of the configuration and system of the monitored application * Garbage Collection: information about the Java heap and pause times * Locking: information about contention on inflated locks * Profiling: sampling profile of Java methods including call paths More information: http://www.ibm.com/developerworks/java/jdk/tools/healthcenter/

Mar 2010 IBM SOA Reference Architecture

What Is Immutable Object?

Immutable object: Immutable objects whose state (i.e. the object's data) does not change once it is instantiated (i.e. it becomes a read-only object after instantiation). Immutable classes are ideal for representing numbers (e.g. java.lang.Integer, java.lang.Float, java.lang.BigDecimal etc are immutable objects), enumeratedtypes, colors (e.g. java.awt.Color is an immutable object), short lived objects like events, messages etc. Benefits of immutable objects • Immutable classes can greatly simplify programming by freely allowing you to cache and share the references to the immutable objects without having to defensively copy them or without having to worry about their values becoming stale or corrupted.

Static Vs. Dynamic Class Loading

Static : Classes are statically loaded with Java's "new" operator. class MyClass { public static void main(String args[]) { Car c = new Car (); } } A NoClassDefFoundException is thrown if a class is referenced with Java's " new" operator (i.e. static loading) but the runtime system cannot find the referenced class. Dynamic loading: Dynamic loading is a technique for programmatically invoking the functions of a class loader at run time. Let us look at how to load classes dynamically. Class.forName (String className ); //static method which returns a Class The above static method returns the class object associated with the class name. The string className can be supplied dynamically at run time. Unlike the static loading, the dynamic l oading will decide whether to load the class Car or the class Jeep at runtime based on a properties file and/or other runtime conditions. Once the class is dynamically loaded the following method returns a...

Adobe Flex 2 - Answering Tough Questions About Enterprise Development

There are cool software tools and there are practical tools. People who make their living by developing enterprise Web applications are very careful in selecting the language or technology for their needs. There is a huge difference in requirements for developing an application like Google maps and the enterprise-grade high availability business applications. Anatole Tartakovsky of Farata Systems (pictured) is one of these programmers who know pretty much everything. He lives and breathes programming. If he does not know the answer to your problem today, he'll know it tomorrow. Flex Developer's Journal have asked Anatole some tough questions that concern most of the enterprise developers who are considering Adobe Flex 2 as a tool for their next Web application. Q . How hard is it for typical Java EE developer with Struts and DAO skills to add Flex to their skill set? A. I would say, the hard part is over. Flex allows seamlessly integrate your Web client with the J...

Adobe Flex Interview Questions

1) What’s the difference between Java and AS3 getters and setters? In Java, getter and setter methods have to be explicitly called. While in AS3, they’re called automatically and externally indistinguishable from public properties. For instance trace(myClass.foo) might be referencing a public property or it might be referencing the method “public get foo():Object”. It makes no difference to an external class. — You can expand on this a bit more to describe why this is useful. The implications are that, unlike in Java, all variables in a class are generally public. Java standard practices are to create only public getters and setters while keeping the variables private. The reason for only allowing methods to be publicly accessible is so that 1) they can be overridden and 2) their implementation can change without altering class interface.