Misc. Shayari

September 15, 2007

Ki Mohammed se vafa tune to hum tere hai
Yeh jahaan cheez hai kya loh-o-qalam tere hai

Yu Tho Syed bhi ho, Mirza bhi ho, Afghan bhi ho
Tum sabhi kuch ho, batao kya musalman bhi ho

Aaj bhi ho jo Ibrahim sa Imaan paida
Aag kar sakti hai andaaz-e-gulistaan paid

Adam ko jab mila to faqat iltajA thA Ilm
Aag me Khaliil ke lab ki dua thaA Ilm
Moosa ko jab milA to tajaLli numA tha Ilm
Bayaniye Mohammed me Noor e Khuda tha Ilm

Ye Ilm hi wahii kabhii ilhaam ho gaya
KaAbe tak aate aate Ali naam ho gay

zakhm e ahsaas na hijrat na safar maaNgegA
ye musaafir to sarai nahi ghar maaNgegA
shahzada abhi kamsin hai to phooloN pe hain paoN
kal jawaaN hogA to insanO ke sir maaNgegA

Basic Dua

September 15, 2007

When beginning the fast– Suhur

وَبِصَوْمِ غَدٍ نَّوَيْتَ مِنْ شَهْرِ رَمَضَانَ Wa bisawmi ghadinn nawaiytu min shahri ramadanI intend to keep the fast for tomorrow in the month of Ramadan
[abu Dawud]

 

When breaking the fast– Iftar

اللَّهُمَّ اِنِّى لَكَ صُمْتُ وَبِكَ امنْتُ [وَعَلَيْكَ تَوَكَّلْتُ] وَعَلَى رِزْقِكَ اَفْطَرْتُ

Allahumma inni laka sumtu wa bika aamantu [wa ‘alayka tawakkaltu] wa ‘ala rizq-ika aftarthu

O Allah!  I fasted for You and I believe in You [and I put my trust in You] and I break my fast with Your sustenance
[“wa ‘alayka tawakkaltu” is quoted in some books of knowledge – but not all, hence it is in brackets]
[abu Dawud]

Java Interview Questions

September 14, 2007

Inheritance: process by which one object acquires the properties of another object. Inheritance allows well-tested procedures to be reused and enables changes to make once and have effect in all relevant places.

Implicit Casting: process of simply assining one entity to another without any transformation guidance to the compiler.

Native method: method that is not implemented in java.

Polymorphism: one name many forms. enables one entity to be used as general category for different types of actions.

Encapsulation: process of binding or wrapping the data and the codes that operates on the data into single entity. This keeps data safe from outside interface and misuse. objects allow procedures to be encapsulated with their data to reduce potential interference. one way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.

Procedural programs: programming logic follows certain procedures and the instructions are executed one after the another. In OOP program, unit of program is object, which is combination of data and code. In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in trun assures the security of the code.

What is OOPs? Object oriented programming organizes a program around its data, ie., objets and a set of welll defined intervaces to that data.

Transient modifier applies to variables only and it is not stored as part or its objects persistent state. Transient variables are not serialized. Volatile modifier applies to variables only and it tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of the program.

Inner class: classes defined in other classes, including those defined in methods are called inner classes. An inner class can have nay accessibility including private. Anonymous class: class defined inside a mthod without name and is instantiated and declared in the same place and cannot have explicit constructors.

Abstract class: class designed with implementation gaps for subclasses to fill in and is deliberately incomplete. Interface: similar to a class which may contain method’s signature only but no body and it is a formal set of methods and contsant declarations that must be defined by the class that implements it. interfaces are usefull for: declaring methods that one or more classes are expected to implement, capturing similarities between unrelated classes without forcing a class relationship.

Servlet Interview Questions

September 13, 2007

The java.servlet.Servlet interface defines 3 methos known as life-cycle method.

  1. public void init(ServletConfig config) throws ServletException: servlet is constructe, then initialized with the init() method.
  2. public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException: any request from client are handled initially by the service() method before delegating to the doXxx() methods in the case of HttpServlet.
  3. public void destroy(): Servlet is removed from service, destroyed with the destroy() method, then garbage collected and finalized.

What is the difference between doGet() and doPost()? : doGet() mthod is limited with 2k of data to be sent, and doPost() mehtod doesn’t have this limitation. A request string for doGet() looks like the following: http://www.google.com/svt1?p1=v1&p2=v2&…&pN=vN. doPost() method call doesntneed a long texttail after a servlet name in a request. All parameters are stored in a request itself, not in a request string, and its impossible to guess the data transmitted to a servlet only looking at the request string.

HttpServlet and GenericServlet: GenericServlet has a service() method aimed to handle requests. HttpServlet extends GenericServlet and addes support for doGet(), doHead() methods (HTTP 1.0) plus doPut(), doOptions(), doDelete(), doTrace() methods. Both these classes are abstract.

ServletContext and ServletConfig: ServletContext defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. The ServletContext object is contained within the ServletConfig object, which the web server provides the servlet when the servlet is initialized.

ServletConfig: the object created after a servlet is instantiated and its default constructor is read. It is created to pass initialization infomation to the servlet.

Maulaa!

September 13, 2007

Mere jism ke lahoo mein basi teri bandagi ki rawani hai. Saanson pe hai kalme tere, labon pe teri kahani hai.

Har zarre mein rawa hai mehka hua sa aks tera, har dil ke gardish mein basa ahasaas tera ruhaani hai.

tujhse hai subha-shaam jale tujhse hi kaaynaat hai, tere hi sajde mein ye zameen junoon-e-aasmani hai.

Aey khuda main tere liye ye jaan nisaar kya karoon, tere jok se hai mujhmei dum tere dum se zindagani hai.

na hindu ke liye hai ghair tu na musalman ke liye paraya, baat-te hain jo tujhe dharmon mein insaan ki ye nadaani hai.

-By purani_jeans_aur_guitar.

Islamic Society of Rancho Cordova (ISRC) – [Masjid Qurtuba?]

September 13, 2007

I begin in the name of Allah, the most Beneficient and Merciful. Alhamdulillah, Sept. 12 2007 (1428 A.H.), blessed is so much this day as we, the Muslim community at Rancho Cordova, have opened a new Masjid so that 5 times daily prayers can be offered. Additionally, this news comes just before the beginning of Ramadhan month. This makes the task of offering tarawih prayers easy.

The community will gather for Maghrib prayer (first prayer at this center) today. Can’t wait… I just can’t wait. This was only possible because of the mercy of Allah (SWT) and the consistent duas of respected brothers at the community.

Takbeer (Allahu Akbar).

Design Patterns

September 13, 2007

Design Pattern is a solution to a general software problem within a particular context. Design patterns allow us to reuse the knowledge of experienced software designers.

Design patterns utilized in Java APIs:

  1. MVC is used extensively throughout Swing API.
  2. The classes java.lang.System and java.sql.DriverManager are examples of the Singleton pattern, although they are not implemented using the approach recommended in the GoF book with static methods.
  3. The Adapter pattern is used extensively by the adapter classes in java.awt.event.
  4. The proxy pattern is used extensively in the implementation of Java’sRemoteMethod Invocation and Interface Definition Language (IDL) features.
  5. The Bridge pattern can be found in the separation of the components in java.awt and their counterparts in java.awt.peer.

How do you make sure only one instance of my class is ever created?

This is an instance where the Singleton desing pattern would be used. You need to make the constructor private and provide a static method to get the sole instance, where the first time the instance is retrieved it is created.

When will you used delegation pattern instead of inheritance to extedn a class’s behaviour?

Since inheritance relationship is defined at compile time, a class cant change its superclass dunamically during program execution. Modifications to a superclass automatically propagate to the subclass. Inheritance creates a strong static coupling between a superclass and its subclasses.

Delegation can be viewed as a relationship between objects where on object forwards certain method calls to another object, called its delegate. The primary advantage of delegation is runtime flexibility- the delgate can easily be changed at runtime. But unlike inheritance, delegation is not directly supported by most popular OO languages, and it doesnt facilitate dynamic polymorphism.

What is data access layer? It receives requests from business layer and speaks to DB, get the result and return to business object. All SQLs and stored procedures will be placed.

Creational patterns: Abstract Factory, Builder, Factory method, Prototyp, Singleton

Structural patterns: Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy

Behavioral patterns: Chain of responsibility, command, iterator

J2EE patterns: MVC, Business Delegate, composite entity, DAO, Front Controller, Service Locator

AbstractFactory: provides one level of interface higher thatn the factory pattern. It is used to return one of several factories. (Uses and benefits: Creates families of related or dependent objects like Kit. Provides a class library of products, exposing interface not implementation. needs to isolate concrete classes from their super classes. A system needs independent of how its products are created, composed and represented.

Singleton: One instance of aclass or one value accessible globally in an application. (uses and benefits: ensure unique instance by defining class final to prevent cloning, may be extensible by the subclass by defining subclass final. make a variable or method public or/and static.

Adapter: convert the existing interfaces to a new interface to achieve compatibility and reusability of the related classes in one application. also known as wrapper pattern. Use and Befits: make unrelated classes owrk together. multiple compatibility. increase transparency of classes. make a pluggable kit. high class reusability.

Bridge: Decouple an abstraction or interface from its implementation so that the two can vary independently. uses and Benefits: want to separate abstraction and implementation permanently. share an implementation among multiple objects. want to improve extensibility. hide implementation details from clients.

Facade: Make a complex system simpler by providing a unified or genreal interface, which is a higher layer to these subsuystems. uses and beneftis: want to reduce complexities of a system. decouple subsystems, reduce its dependency, and improve protability. make an entry point to your subsystems. minimize the communication and dependency between subsystems. security and performance consideration. shield clients from subsystem components.

MVC: architecture design pattern. model means data, view means representation and controller means representation and controller works on data and representation. MVC focuses to decouple the triad relationship between model, controller and view. improves maintainability, increase object reusabnility, achieve design flexibility.

Business delegate: intermediate class decouples between presentatio-tier clients and business services. Uses and benefits: simplify the complicated relationship, reduce coupling, cache results and references to remote busines services.

DAO: adapt a uniform interface to access multiple db like relational, unrelational, object oriented etc. Uses and benefits: need to access multiple data sources like legacy systems, B2B, LDAP, and so forth. Lack of uniform APIs to address the requirements to access disparate systems. Persisten storage APIs vary depending on the product verndor. Adapt and encapsulate all access to the DS. hide DS implementation details from its clients. more portable and less code dependencies in components.

UML interview questions (Unified Modeling language)

September 13, 2007

What is UML? graphical language for visualizing, specifying, constructing and documenting the artifacts of the system. allows to create blueprints of all the aspects of the system, before physically implementing the system.

What is modeling? What are the advantages of creating a model? Well-accepted engineering technique which helps build a model. Model is the simplification of reality; blueprint of the system that needs to be built. Model helps you visualize the system. helps to specify the structural and behaviour of the sytem. helps make templates for constructing the system. helps document the sytem.

What are the different views considered when building an object-oriented software system? there aer 5 veiws:

  1. Use case view: exposes requirements of a system.
  2. Design view: capturing the vocabulary
  3. process view: modeling the distribution of the sytems processes and threads.
  4. implementation veiw: addressing the physical implementation of the system.
  5. deployement view: focus on the modeling of components required for deploying the system.

What are the major three types of modeling used? they are 9: Use case diagram, class diagram, object diagram, sequence diagram, statechart diagram, collaboration diagram, activity diagram, component diagram, deployment diagram.

SDLC: Software development life cycle. SDLC of a system includes processes that are Use case driven, architecture centric and iterative and incremental. Life cycle is divided into phases. Phase is a time span between two milestones. The milestones are Inception, Elaboration, construction, and transition. Process workflows that evolve through these phase are Business Modelling, Requirement gathering, Analysis and Design, Implementation, Testing, Deployment. Supporting workflows are configuration and change management, Project management.

What are relationships?

  1. Dependencies: relationship between two entities such that a change in specification of one thing may affect the other. used to show that one class uses another class as an argument in the signature of the operation.
  2. Generalization: relationships specified in the class subclass scenario, it is shown when one entity inherits from other.
  3. Associations: structural relationships. ‘A room has walls’, ‘Person works for a company’.
  4. Aggregation: type of association where there is-a, has-a relationship.
  • Static Diagrams (Structural diagrams): Class diagram, Object diagram, component diagram, deployment diagram.
  • Dynamic diagram(Behavioral diagrams): Use case diagram, sequence diagram, collaboration diagram, activity diagram, statechart diagram.

Messages: Specification of a communication, when a message is passed that results in action that is in turn an executable statement.

Use Case: specifies the behavior of a system or a part of a system. Involves the interaction of actors and system.

Aggregation: One class owns but shares a reference to objects of another class. Child refrerence exists even if parent oject rereference is set to null. Symbol: empty diamond arrow.

Composition: one class contains objects of another class. child reference does not exists independently. Symbol: filled diamond arrow.

Stereotype: Extension to existing UML vocabulary. It is used to create new model elements or derive from existing ones having specific properties pertaining to problem domain. EG: you can create steriotype, <<interface>> derived from existing one, <<class>>.

JSP Interview Questions (Important)

September 12, 2007

So you have an interview…hmmm… yeah… as you are looking thru these questions probably someone who likes to take the interview is also going through these. Trust me! :-). For more please find them at http://www.roseindia.net. I have only few here for my own reference: hehe

JSP Action:

  • JSP actions are XML tags that direct the server to use existing components or control the behavior of the JSP engine.
  • Consist of typical (XML-base) prefix of ‘jsp’ followed by a colon, followed by the action name followed by one or more attribute parameters. For example: There are six JSP Actions: <jsp:include/>, <jsp:forward/>, <jsp:plugin/>, <jsp:usebean/>, <jsp:setProperty/>, <jsp:getProperty/>

What is the difference between <jsp:include page = ... > and
<%@ include file = ... >?

Both the tag includes the information from one page in another. The differences are as follows: <jsp:include page = ... >: This is like a function call from one jsp to another jsp. It is executed ( the included page is executed and the generated html content is included in the content of calling jsp) each time the client page is accessed by the client. This approach is useful to for modularizing the web application. If the included file changed then the new content will be included in the output.

<%@ include file = … >: In this case the content of the included file is textually embedded in the page that have <%@ include file=”..”> directive. In this case in the included file changes, the changed content will not included in the output. This approach is used when the code from one jsp file required to include in multiple jsp files.

What is the difference between <jsp:forward page = ... > and
response.sendRedirect(url)
?

The <jsp:forward> element forwards the request object containing the client request information from one JSP file to another file. The target file can be an HTML file, another JSP file, or a servlet, as long as it is in the same application context as the forwarding JSP file.
sendRedirect sends HTTP temporary redirect response to the browser, and browser creates a new request to go the redirected page. The response.sendRedirect kills the session variables.

Implicit objects available to JSP:

http://www.roseindia.net/interviewquestions/jsp-interview-questions.shtml

Life-cycle methods of JSP:

  1. jspInit(): Container calls jspInit() to initialize the servlet instance. It is called bfore any other method, and is called only once for a servlet instance.
  2. _jspService(): The container calls the _jspservice() for each request and it passes the request and the response objects. This method cannot be overriden.
  3. jspDestroy(): container calls this when its instance is about to be destroyed.

How will you handle runtime exception in your jsp page?

‘errorPage’ attribute of the page directive can be used to catch runtime exceptions automatically and then forwarded to an error processing page. For example: <%@ page errorPae=”dbaccessError.jsp” %> forwards request to dbaccessError.jsp pge if an uncaught exception is encountered during request processing. Within “dbaccessError.jsp”, you must indicate that it is an error processing page, via the directive: <%@ page isErrorPage=”true” %>.

How can you enable session tracking for JSP pages if the browser has disabled cookies: We can enable session tracking using URL rewriting. URL rewriting includes the sessionID within the link itself as a name/value pair. However, for this to be effective, you need to append the session Id for each and every link that is part of your servlet response. adding sessionId to a link is greatly simplified by means of a couple of methods: response.ecnodeURL() associates a session ID with a giver UIRl, and if you are using redirection, response.encodeRedirectURL() can be used by giving the redirected URL as input. Both encodeURL() and encodeRedirectURL() first determine whether cookies are supported by the browser; is so, the input URL is returned unchanged since the session ID wil lbe persisted as cookie.

Which is better fro threadsafe servlets and JSPs? SingleThreadModel Interface or Synchronization? Although the SingleThreadModel technique is easy to use, and works well for low volume sites, it does not scale well. JSps can be made thread safe by having them implement the SingleThreadModel interface. This is done by adding the directive <%@ page isThreadSage=”false” %> withi n your JSP page. With this, instead of a single instance of the servlet generated for your JSP page loaded in memory, you will have N instance of the servlet loaded and initialized, with the service method of each instance effectively synchronized.

How do I prevent the output of my JSP or servlet pages from being caches by the browser?

Set the appropriate HTTP header attributes to prevent the dynamic content output by the JSP page from being cached by the browser. Execute the following scriptlet at the beginning of JSP pages to prevent them from being caches at the browser.

<%
response.setHeader(“Cache-Control”,”no-store”); //HTTP 1.1
response.setHeader(“Pragma\”,”no-cache”); //HTTP 1.0
response.setDateHeader (“Expires”, 0); //prevents caching at the proxy server
%>

Websphere Interview Questions

September 12, 2007

How to choose websphere over other application servers?

Selecting application server is part of architechtural process when infrastructure is defined. It depends on several facots:

  1. External systems your application will be interacting
  2. Type of application you have
  3. Target availability of system.
  4. Corporate standards
  5. Budget.

What are deployment descriptors? How many types of Deployment descriptors are available? What are they?

Deployment descriptor is an XML file that describes how to deploy a module or application by specifying configuration and container options. For example, an EJB deployment descriptor passes information to an EJB container about how to manage and control an enterprise bean. There are two types of deployment descriptor in websphere: Web application deployment descriptor and portlet deployemnt descriptor

Portlets are packaged as WAR files with a web application deployment descriptor (web.xml). This defines each portlet as a servlet within the web application, including unique identifiers for each portlet, the portlet class, and initialization parameters.

How many ways can you deploy applications in websphere?

  1. Directly copy files to deployedapplication folder in websphere- hot deployment.
  2. use websphere specific ant tasks and building automated scripts for deploying application.
  3. through administration console.

What is the difference between web server and application server?

ApplicationServer: takes care of Security, Transaction, Multithreading, Resource pooling, load balancing, clustering, performence, highly availability, scalability, etc. Exposes business logic to client applications through various protocols, possibly including HTTP. Supports deployment of .war and .ear filesApplication server = webserver + EJB container.

Webserver: handles HTTP protocol. Receives HTTP request, it responds with an HTTP response.

How to import jaxp package in IBM WSAD?

  1. open WSAD
  2. go to project
  3. click properties
  4. select javaBuildPath
  5. add any jar file like jaxp select add external jars.

How to implement JDBC-ODBC bridge driver (Type 1) in Websphere?

If you use JDBC type (I) driver you dont need to add any driver in websphere. you simply created DSN and use it locally, same we use java class, if you use Type(2) and Type(4) so first go to admin console then go to connection, then add driver there fill other info like conn. size, uname pass, max conn. and connect it to you applications.

Is there any difference between weblogic and websphere?

Webpshere tends to focus more on integration, connectivity and web services. it has rich implementation of J2EE, better performance, more extensive integration and transaction management. In terms of trnsaction weblogic is having default transaction attribute as ‘supports’, but websphere does not have any default transaction attribute. (reference: http://www.geekinterview.com)