Directory
Technology
Blog Details for "Interview Questions in Java and Java EE"
Interview Questions in Java and Java EEInterview Questions in Java and Java EEInterview Questions on Core Java and Java EE Articles
Core Java Interview Questions
2015-04-03 17:38:00 Every year many thousand technocrats choose Java careers across the globe,after formally taking Java training classes,courses and/or Java certifications like SCJP etc.While appearing for technical interviews,these budding Java programmers face variety of technical questions, are asked to write code snippets to prove their mettle in relevant topics of Java.They are not only assessed on language basics but also on their familiarity with Java development tools, optimization of Java code,load tests,securing code through Java obfuscation and more. It is their performance in these interviews which decides their career fate and is highly dependent on to-the-point and not too verbose answers.What prompted me to create a blog on frequently asked and and not so frequently asked tricky Java interview questions? The answer is,as I have been through various technical interviews on Java and related technologies for all my career spent with this fascinating technology so I thought of sharing these... More About: Questions , Interview , Core
Java EE Interview Questions
2015-04-02 12:00:00 I hope my post on Java Interview Questions will be doing some good to all my targeted audience on Core Java and in this blog, I have essentially focussed on interview questions in several Java EE technologies(erstwhile J2EE).Apart from Java EE, I will also be covering interview questions on most widely used open source technologies like Struts,Hibernate,Spring and Velocity and more.I have constantly been asked by my readers to put something on personal interview questions, consequently, you may like to read my post on personal interview questions prior talking about Java Enterprise Edition.Sun Microsystems introduced Java EE 5 specification under JSR 244 and the final release was made public on May ,2006.Java EE has become a cornerstone technology for enterprise level web based solution development.It has more than three million downloads and more than twenty six vendors' application servers support this specification.I believe,it is significant to go through an introduction of Ja...
Master List Of Code Snippets
2015-01-26 15:18:00 XML Parsing Using SAXFile OperationsExperimenting with java.util.Date.Using java.lang.reflect.* APIsUsing java.lang.Comparable.* interfaceThread Interruption More About: Code , List , Master , Mast , Aster
Java Coding Standards:Documentation
2008-05-23 12:51:00 A proper documentation of code ensures better maintainability and code management.Writing documentation may not be fun but it is necessary.The focus is practical tips, practices to be followed religiously while documenting code . When you are a beginner in coding world this seems to be a insignificant and time consuming exercise but as you grow in experience you know how important it is to follow such practices in code, so that relevance and meaning of each part of code become evident to anyone going through the code.Some documentation tips that may make programmer fraternity happy: Documentation comment should not be more than 80 characters. If it is unavoidable, use paragraphs. Create comments for protected and public variables,methods and class.Give them meaningful names, if you do so then you may require less effort in description of your code. The first sentence of each documentation comment is a summary sentence (crisp and informative).It contains a concise but complete descri... More About: Standards , Java , Coding
Java Coding Standards : Layout
2008-05-17 10:04:00 In professional Java programming world, it is essential that your developed code should follow some coding standards as per guidelines set by your organization or your client is technical enough to send you those details. A question arises why do I need such a practice, answer is very simple. To make life easy for those who are going to maintain or enhance your code. A better documented, neat-clean code with all programming standards and guidelines followed does not only enhance maintainability but also performance and robustness of your code. You may find these details to start with at Sun's website.The coding conventions set by Sun for Java recommends that others should ideally follow and no harm in transforming it to suit your organizational or clients' needs . It covers filenames, file organization, indentation, comments, declarations, statements, white space, naming conventions, programming practices and includes a code example.The purpose of programming standards is t... More About: Standards , Coding , Layout
What is obfuscation? How this technique works in Java?
2008-05-13 08:31:00 Java code gets compiled in bytecode and getting this bytecode decompiled with readily available Java decompilers makes it unsafe. The code obfuscation is a technique with which Java code can be protected. A threat to reverse engineer Java code has been taken very seriously. As the language was designed to be compiled into bytecode which is portable and can get executed within its own runtime environment(JVM), reverse engineering of bytecode posed a threat to intellectual property. The protection of code using encryption and decryption techniques,through software is not a good solution as it is always susceptibile to be decoded.Java code obfuscation is a technique which with some additional logical changes like changing the names of variables, methods and logical changes in control blocks of compiled code are done.Various freeware,shareware Java obfuscators use combinations of such techniques.Now when such Java code is decompiled then it becomes costly in terms of time and effort to ... More About: Java , Technique , Works
Apache AXIS with IBM's WSAD/RAD
2008-04-17 18:33:00 All major IDEs from different Vendors support webservices using Apache Axis .In this post my objective is to demonstrate a simple web service development and deployment using IBM's Websphere Application Developer(WSAD)/Rational Application Developer(RAD).They both provide support for Apache Axis and can use Axis libraries as required for runtime environment for web services.In following heads all the steps involved are explained:Configure Axis as runtime for Web services in RAD -Start RAD/WSAD. Open a new workspace, and close the welcome screen.-In WSAD/RAD,go on menu, Window >Preferences >Web Services >Server and RuntimeDo the settings for Apache Axis runtime as shown in the Figure 1.Figure 1Create a new Web Project Now we have a plain java class and a web project. Next step is to create a web service out of this class and embed it into this Web project-Switch to J2EE perspective, and create a new Dynamic Web project with name 'AxisExample'.Figure 2Create a simple java class whic...
Webserivces With Apache Axis Continued...
2008-04-17 18:23:00 In continuation with my previous post,this post explores various ways of deploying a webservice using Apache Axis and how stubs can be generated with tools provided in Apache Axis.Deploying A Webservice:Web services can be deployed in axis in two ways-JWS (Java Web Service) Files - Instant Deployment-Custom Deployment - Introducing WSDDJWS Deployment:-Copy the *.java file into your web directory, and rename it *.jws.-You're done!You should now be able to access the service at the following URL (assuming your Axis web application is on port 8080):http://localhost:8080/axis/Calculat or.jwsAxis automatically locates the file, compiles the class, and converts SOAP calls correctly into Java invocations of your service classCustom Deployment - Introducing WSDD:Axis uses *.wsdd files to deploy Web services. This is a Axis specific format for deploying custom web services.Steps to Deploy a Class File as Webservice:-Create the class file.-Write a deploy.wsdd file for that class-Run AdminClie...
Webservices, Apache Axis Way
2008-04-16 19:45:00 AXIS,is a complete frame work for developing and assessing Web Services.The current stable version of Axis in use is 1.2,though Axis 2 is on the anvil of release.You can find more information and download information about Axis C++ and Java on their official website.Axis is essentially a SOAP engine.It is an implemetation of SOAP which provides abstarction from dealing with SOAP and WSDL directly.You can always write webservices without Axis but it will be a very tedious job then.Axis2 is SOAP 3.0 which is written from scratch,the intention is to create a more modular, more flexible, and higher-performing SOAP implementation (relative to Apache SOAP 2.0).Axis provides a framework for constructing SOAP processors such as clients, servers, gateways, etc. Axis supports both Java and C++.But Axis isn't just a SOAP engine -- it also includes:-a simple standalone server.-a server which plugs into servlet engines such as Tomcat.-extensive support for the Web Service Description Language (...
How to register Web Services with UDDI4j?
2008-04-15 20:15:00 Here we go with a snippet of code to register a web service using UDDI4j****BEGIN****proxy.setPublishURL(ud diPublishingURI);AuthToken token = proxy.get_authToken(mUserName, mPassword);Vector entities = new Vector();BusinessEntity be = new BusinessEntity("", mBusinessEntityName);// set all related dataBusinessDetail bd = proxy.save_business(token.getAuthInfoStri ng(), entities);Vector businessEntities = bd.getBusinessEntityVector();BusinessEnti ty returnedBusinessEntity = (BusinessEntity) (businessEntities.elementAt(0));mServiceK ey = returnedBusinessEntity.getBusinessService s().get(0).getServiceKey();****END****'mS erviceKey' will be used to extract to get URL of a registered Service from a UDDI Registry,and here is another snippet which helps you in locating a service :****BEGIN****UDDIProxy proxy = new UDDIProxy();proxy.setInquiryURL("http://l ocalhost:9090/juddi/inquiry");ServiceDeta il serviceDetail = proxy.get_serviceDetail(mServiceKey);Vect or businessServiceVector = new Vector();b... More About: Services , Web Services , Register
Simplifying Service Oriented Architecture
2008-04-12 06:35:00 What is SOA?Why SOA?What are the constituents of SOA?Who suits best for SOA?When to avoid implementation of SOA?How to avoid risks in SOA implementation?How SOA makes things better or even worse? More About: Architecture , Service
How to develop,test and maintain SOA based solutions?
2008-04-11 19:07:00 Most significant part of any development life cycle is Analysis and Design phase and SOA is also not an exception.IBM has been consistently working in direction to lay down systematic approaches to identify and realizes services for SOA.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. Web services are network based collection of business logic whic... More About: Test , Solutions , Develop
How SOA makes things better or even worse?
2008-04-11 19:05:00 With all the hype that SOA has brought to organizations, they have to brainstorm whether this will do any good to their business anyway.The organizations first have to understand that SOA can not be implemented by introduction of certain software products or services but it is an architectural approach which has to analyze existing systems,IT resources,ever changing business processes and requirements and comes up with a set of business aligned services which can cost effectively fit very well for a consistent business functioning for years to come. As discussed in my previous blog , SOA projects can easily be put into red zone if all its constituents are not well planned,managed and executed.A change is like oxygen for an organization and SOA has to help businesses adapt with changing times and technology too changes rapidly beyond our imagination and in these times keeping an IT plan for next ten years for an organization is a daunting task.No matter how smart we think SOA can ta... More About: Things
How to avoid risks in SOA implementation?
2008-04-11 19:00:00 SOA project may go haywire if things are not planned,managed and designed properly.It is very important to know your customer's requirements,expectations and improved business processes in advance before starting any analysis and design exercise.A continuous communication with your client is must so that you can understand their business processes very well and should be able to identify problem areas with some concrete solutions in mind.If you have a suggestions related to business processes improvement then get an approval from your client on business requirements as they keep changing all the time.So scope of work is clearly defined to you and your customer with extensive project planning.If a customer does not see any qualitative improvement in complex business processes simplification/replacement with new improved business processes,he is going to make a lot of hue and cry about introducing new technological architecture.An organisation is always interested in synchronisation ... More About: Avoid , Implementation
When to avoid implementation of SOA?
2008-04-11 18:57:00 SOA offers a change in perspective, a paradigm shift from object oriented to service oriented.As for almost a decade, most of the development is done using Object oriented technologies and that led to tight coupling many a times with vendor specific technologies like CORBA,DCOM or RMI.SOA offers to a new thinking of services rather visualizing in terms of objects which makes it independent of underlying technology. If SOA implementation in an organization is not well thought of,planned and micro-detailed then it may lead to disaster, waste of valuable resources of time and money.SOA may not be a good idea for enterprises which are not too big and complex in their business process and do not depend upon business processes of its suppliers and business partners.For instance, if an organisation which has distributed applications across the differ net geographies then it will be a good idea to implement SOA to integrate various applications to provide one cost effective,scalable and fu... More About: Avoid , Implementation
Who suits best for SOA?
2008-04-11 18:55:00 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. SOA has opened new vistas to re-orient business on disintegrating business processes into services based over business components in such a way that existing business solutions and previously non communicating systems can also fit into the big picture.In a way it has g... More About: Suits
What are the constituents of SOA?
2008-04-11 18:54:00 There has been lot of terms which have been surfaced to define constituents of SOA delivery process and specially IBM has been actively coining new terms in order to streamline how SOA based solutions be developed. Service-Oriented Analysis and Design (SOAD)Service-Oriented Modeling and Architecture (SOMA)Business-Driven Development (BDD) I will try to briefly describe and simplify these terms. There is no formal definition of SOAD as yet from IBM.SOAD takes a hybrid approach of Object Oriented Analysis and Design(OOAD),Enterprsie Architecture(EA) frmawork and Business Process Management(BPM) approaches for SOA based solutions development. As per Gartner, more than 60% mission critical applications of various enterprises will be built using SOA by 2008.So that's what whole hype all about SOA. SOMA lays out details of how SOA based solutions can be compartmentalized.It includes analysis and design aspects which have major focus on identification,specification and realization of S...
Why SOA?
2008-04-11 18:49:00 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...
What is SOA?
2008-04-11 18:43:00 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.It is an interface or gateway for one program/device/system to have a controlled access over a network to other program/device/system like humans need some sort of GUI...
What is AJAX? Explain in detail how it works.Discuss its advantages and dis
2008-04-09 16:18:00 AJAX stands for Asynchronous Javascript and XML which is used for developing dynamic web applications. This concept was not new, as a matter of fact asynchronous loading of content without a full reload was existing for a long time.It was known as web remoting or remote scripting. AJAX requests data from server in an asynchronous fashion in background without affecting the presentation layer.Hence Ajax interactions allow for a clear separation of presentation logic from the data. In Rich Internet Applications(RIA) , an HTML document acts as a template or container where content is injected, based on client events using XML data retrieved from a server-side component.The functioning of data exchange between web browser and server occurs with XMLHttpRequest object is used which is inherent with JavaScript technology.It is supported by most of the browsers like IE7.0,Mozilla's Firefox,Safari etc. In AJAX applications, as HTTP requests are made completely in the background, the ... More About: Works
Some commonly used validations like EMail,Phone Number,SSN,Numeric values t
2008-03-29 19:12:00 import java.util.regex.Matcher;import java.util.regex.Pattern;public class RegularExpressionExample { /** * @param args */ public static void main(String[] args) { System.out.println("Validating Email :" + isEmailValid("abc@xysss.comccccc")); System.out.println("Validating Phone Number :" + isPhoneNumberValid("1234567798")); System.out.println("Validating SSN:" + isSSNValid("23456-werfdf")); System.out.println("Validating Numeric Values :" + isNumeric("-1234")); } public static boolean isEmailValid(String aEmail) { boolean isValid = false; /* * Examples:The following email addresses will pass validation * asdf@tttdd.com xyzzz@tyyy.in zxg.asd@tx.govt */ String emailExpression = "^[\w\.-]+@([\w\-]+\.)+[A-Z]{2,4}$"; CharSequence inputStr = aEmail; Pattern pattern = Pattern.compile(emailExpression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { isValid = true; } return isValid; } /** * isPhoneNumb...
Is it necessary to declare something that is private,a static as well as th
2008-03-23 07:38:00 The answer to this question is 'No'. Something(a variable/class/method) is declared static when there is just one copy of the same is required per class/JVM and not multiple copies dependent on objects of the class.In case of inner classes you can get more details on Java Language Specifications website available here. More About: Private , Static
Sending EMail To GMail SMTP Server Using Java Mail APIs
2008-03-19 18:05:00 import java.security.Security;import java.util.Properties;import javax.mail.Message;import javax.mail.MessagingException;import javax.mail.Session;import javax.mail.Transport;import javax.mail.internet.InternetAddress;impor t javax.mail.internet.MimeMessage;/** * This application will require Java Mail API and which can be downloaded from * http://java.sun.com/products/javamail/dow nloads/index.html JavaBeansTM * Activation Framework extension or JAF (javax.activation) can be downloaded * from * http://java.sun.com/javase/technologies/d esktop/javabeans/jaf/downloads/index.html . * * @author pundeerd * * */public class MailingApplication { /** * @param args */ public static void main(String[] args) { // recepients String[] to = { "abc@gmail.com" }; String subject = "Test Email "; String message = "Hello there"; // sender String from = "xyz@gmail.com"; try { postMail(to, subject, message, from); } catch (MessagingException e) { e.printStackTrace(); } } private static voi... More About: Gmail , Server
Write Into An Excel File Using Java
2008-03-18 18:30:00 In order to write content to an MS Excel sheet you are required to download JExcel APIs from here.package example;import java.io.File ;import java.io.IOException;import java.io.InputStream;import java.util.Locale;import java.util.Properties;import jxl.Workbook;import jxl.WorkbookSettings;import jxl.format.Colour;import jxl.write.Label;import jxl.write.WritableCellFormat;import jxl.write.WritableFont;import jxl.write.WritableSheet;import jxl.write.WritableWorkbook;import jxl.write.Write Exception;public class JExcelExample { int mCount = 0; public static void main(String[] args) { try { boolean isOutputFolder = false; JExcelExample jexcel = new JExcelExample(); Properties prop = jexcel.loadProperties(); String sheets = prop.getProperty("org.sheets"); File directory = new File(prop.getProperty("output.folder")); if (!directory.exists()) { isOutputFolder = directory.mkdir(); } else { ... More About: Java
Get Locale Specific Date
2008-03-18 18:03:00 import java.text.DateFormat;import java.util.Date;import java.util.Locale;public class LocaleDate { /** * @param args */ public static void main(String[] args) { Locale americanLocale = new Locale("en", "US" ); Locale germanLocale = new Locale("de", "DE"); DateFormat americanFormat = DateFormat.getDateInstance(DateFormat.SHO RT, americanLocale); DateFormat germanFormat = DateFormat.getDateInstance(DateFormat.SHO RT, germanLocale); Date date = new Date(); System.out.println(americanFormat.format( date)); System.out.println(germanFormat.format(da te)); }} More About: Specific
How to handle duplicate submits in Struts?
2008-02-10 09:58:00 The duplicate form submission occurs-When a user clicks the Submit button more than once before the response is sent back or- When a client accesses a view by returning to a previously bookmarked page.It may result in inconsistent transactions and must be avoided.In Struts this problem can be handled by using the saveToken() and isTokenValid() methods of Action class. saveToken() method creates a token (a unique string) and saves that in the user's current session, while isTokenValid() checks if the token stored in the user's current session is the same as that was passed as the request parameter.It can be done by loading JSP through an Action and before loading the JSP call saveToken() to save the token in the user session. When the form is submitted, check the token against that in the session by calling isTokenValid().public ActionForward submitOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{try{// check the... More About: Handle
What are Tag Libraries provided with Struts?
2007-11-28 11:37:00 Struts supports following tag libraries:a).Bean Tags: All tags which correspond to struts-bean.tld provide capability of accessing beans related activities.b).HTML Tags: All tags which correspond to struts-html.tld used for HTML UI/Forms creation. c).Logic Tags: All tags which correspond to struts-logic.tld manages condition based logic,iterate over a statement based on some logic and application flow management. d).Nested Tags: All tags which correspond to struts-nested.tld make it easy to manage nested beans.e).Template Tags: All tags which correspond to struts-template.tld used for template creation while providing better maintenance of such websites. f). Tiles Tags: All tags which correspond to struts-tiles.tldJava Standard Tag Library (or JSTL as it's known), provides a specification for four separate areas of concern: * Core * XML Processing * Internationalization * DatabaseThe spe... More About: Struts , Ovid , Libraries
What are the core classes of the Struts Framework?
2007-11-28 07:17:00 The classes which are at core of Struts Framework can be enumerated as given below:- org.apache.struts.action.Action- org.apache.struts.action.ActionForm- org.apache.struts.action.ActionMapping- org.apache.struts.action.ActionServlet - org.apache.struts.action.ActionForward More About: Classes , Core
What are the differences between ActionErrors and ActionMessage?/Wat are th
2007-11-26 06:38:00 To summarize, the difference between the classes ActionErrors/ActionError/ActionMess ages/A ctionMessage has absolutely nothing to do with the difference in behavior in Action.saveErrors(...) and Action.saveMessages(...) The difference between the classes is zero -- all behavior in ActionErrors was pushed up into ActionMessages and all behavior in ActionError was pushed up into ActionMessage. This was done in the attempt to clearly signal that these classes can be used to pass any kind of messages from the controller to the view -- errors being only one kind of message. The difference between saveErrors(...) and saveMessages(...) is simply the attribute name under which the ActionMessages object is stored, providing two convenient default locations for storing controller messages for use by the view. If you look more closely at the html:errors and html:messages tags, you can actually use them to get an ActionMessages object from any arbitrary attribute name in any scope. The differenc... More About: Differences , Diff
Velocity Framework
More articles from this author:2007-11-19 08:27:00 What is Velocity Framework ?Velocity is a Java based template engine.It permits anyone to use a simple yet powerful template language to reference objects defined in Java code.Velocity is inspired from 'WebMacro' , an alternative to JSP,PHP and ASP( www.webmacro.org).Where can Velocity be used?Velocity framework can be used in following areas:- Web apps, dynamic HTML pages are created and processed with VelocityViewServlet or number of frameworks that support Velocity - Source code generation- Automatic e-mails- XML transformation, provides an ant task called Anakia which reads an XML file and makes it available to a Velocity template. What are the features of Velocity?Velocity framework has following features:- Velocity is MVC based- It segregates HTML template code from Java code- It emphasizes on role based web app development - Velocity offers better maintainable web applicationsHow Velocity works?When using Velocity in an application program or in a servlet (or anywhere, ac... 1, 2, 3, 4 |



