Tuesday, November 30, 2010

Interview with JDA Hyderabad

1. Same class name in two different war files
2. Create own datastrucutre
3. Jsp usebeans
4. Servlet context implemetation
5. Log4j impl
6. Bottom 3 salaries
7. Spring why?
8. Sax vs Dom



======================================================
Q1. Same class name in two different war files
http://www.redbooks.ibm.com/redpapers/pdfs/redp4307.pdf

Q3. Jsp usebeans vs import


This checks if an object called "myBean" exists in the session
attributes, and if necessary creates and puts it there. It also adds a
variable called "myBean" that can be referenced later, in e.g.
<%=myBean.getFoo()%>.

When you develop a bean to be used in a JSP page, I recommend that you make it part of a named package. A Java class that does not use a package statement ends up in the so-called unnamed package. The servlet class generated from the JSP page is, however, typically assigned to a named package. If you try to refer to a class in the unnamed package from a class in a named package, Java cannot find the class unless you use an import statement to import it. In a JSP page that means you must use both a page directive to import the class, and the action to make it available:

<%@ page import="UserInfoBean" %>


If the bean is part of a named packed, the action is all you need:

class="com.mycompany.UserInfoBean" />

Saturday, November 27, 2010

Interview with Proxxxxx in Hyderabad

Questions and answers
=====================
1. Spring instance check
2. How to maintain inserted order in Set
3. Xsd include vs Import
4. why should we overide hashCode and equals
5. immutable collection
6. String intern
7. Template design pattern
8. Any other soa
9. Builder
10. Abstract constructor
11. Soap action
12. Soap method
13. Jms
14. Spring jms
15. Spring aop core
16. Dwr
17. Drools
18. Int n=null

==============================================================================
Q2. How to maintain inserted order in Set
LinkedHashSet - maintain inserted set
TreeSet - Sorted set

Q3. Xsd include vs Import
The difference between the include element and the import element is that import element allows references to schema components from schema documents with different target namespaces and the include element adds the schema components from other schema documents that have the same target namespace (or no specified target namespace) to the containing schema. In short, the import element allows you to use schema components from any schema; the include element allows you to add all the components of an included schema to the containing schema.

Q4. why should we overide hashCode and equals
Objects that are equal according to the equals method must return the same hashCode value

If two objects are not equal according to equals, they are not required to return different hashCode values.

Hash code equal but not the strings
public static void main(String[] args) {
String str1 = "2L";
String str2 = "3-";

System.out.println("String equality: " + str1.equals(str2));
System.out.println("HashCode eqauality: " + (str1.hashCode() == str2.hashCode()));
}

Q5. immutable collection
public static Collection unmodifiableCollection(Collection c)

Q6. String intern()
Returns a canonical representation for the string object.

A pool of strings, initially empty, is maintained privately by the class String.

When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.

Q7. Builder Pattern


The telescoping constructor anti-pattern occurs when the increase of object constructor parameter combination leads to an exponential list of constructors. Instead of using numerous constructors, the builder pattern uses another object, a builder, that receives each initialization parameter step by step and then returns the resulting constructed object at once.

Definition[edit]

The intent of the Builder design pattern is to separate the construction of a complex object from its representation. By doing so the same construction process can create different representations. [2]

Advantages[3][edit]

  • Allows you to vary a product’s internal representation.
  • Encapsulates code for construction and representation.
  • Provides control over steps of construction process.

Disadvantages[3][edit]

  • Requires creating a separate ConcreteBuilder for each different type of Product.
  • Requires the builder classes to be mutable.

References: https://en.wikipedia.org/wiki/Builder_pattern



Friday, November 26, 2010

JSP interview questions

1. What are the implicit objects in JSP?


Q & A
1. What are the implicit objects in JSP?
A. There are nine implicit objects. Here is the list of all the implicit objects:
Object Class
application javax.servlet.ServletContext
config javax.servlet.ServletConfig
exception java.lang.Throwable
out javax.servlet.jsp.JspWriter
page java.lang.Object
PageContext javax.servlet.jsp.PageContext
request javax.servlet.ServletRequest
response javax.servlet.ServletResponse
session javax.servlet.http.HttpSession

* Application: These objects has an application scope. These objects are available at the widest context level, that allows to share the same information between the JSP page's servlet and any Web components with in the same application.
* Config: These object has a page scope and is an instance of javax.servlet.ServletConfig class. Config object allows to pass the initialization data to a JSP page's servlet. Parameters of this objects can be set in the deployment descriptor (web.xml) inside the element . The method getInitParameter() is used to access the initialization parameters.
* Exception: This object has a page scope and is an instance of java.lang.Throwable class. This object allows the exception data to be accessed only by designated JSP "error pages."
* Out: This object allows us to access the servlet's output stream and has a page scope. Out object is an instance of javax.servlet.jsp.JspWriter class. It provides the output stream that enable access to the servlet's output stream.
* Page: This object has a page scope and is an instance of the JSP page's servlet class that processes the current request. Page object represents the current page that is used to call the methods defined by the translated servlet class. First type cast the servlet before accessing any method of the servlet through the page.
* Pagecontext: PageContext has a page scope. Pagecontext is the context for the JSP page itself that provides a single API to manage the various scoped attributes. This API is extensively used if we are implementing JSP custom tag handlers. PageContext also provides access to several page attributes like including some static or dynamic resource.
* Request: Request object has a request scope that is used to access the HTTP request data, and also provides a context to associate the request-specific data. Request object implements javax.servlet.ServletRequest interface. It uses the getParameter() method to access the request parameter. The container passes this object to the _jspService() method.
* Response: This object has a page scope that allows direct access to the HTTPServletResponse class object. Response object is an instance of the classes that implements the javax.servlet.ServletResponse class. Container generates to this object and passes to the _jspService() method as a parameter.
* Session: Session object has a session scope that is an instance of javax.servlet.http.HttpSession class. Perhaps it is the most commonly used object to manage the state contexts. This object persist information across multiple user connection.

JMS tutorial

http://www.hartmannsoftware.com/JMS_Tutorial.pdf

Tuesday, April 13, 2010

microdata

There are three formats available (mostly used)

1. Microdata

2. Microformat

3. RDFa
They represent different trade-offs in terms of ease of authoring versus expressibility.

<span style="font-size:130%;">Interesting facts about microdata:
Microdata is HTML5 microdata specification. It is a way to label the content data to describe specific type of information. This doesn't supported by Yahoo
Ex: Person, Event, ....

Microdata uses the simple html tags div or span

Ex1: <div itemscope="" itemtype="http://data-vocabulary.org/Person">
My name is <span itemprop="name">Bob Smith,
but people call me Smithy.
Here is my homepage:
.
I live in
<span itemprop="address" itemscope="" itemtype="http://data-vocabulary.org/Address">
<span itemprop="locality">Albuquerque,
<span itemprop="region">NM

and work as an <span itemprop="title">engineer
at <span itemprop="affiliation">ACME Corp.




Ex2:


Rating: 8.5

Interesting facts about microformat:
Microformats are the easiest to write and understand, but may not fill all your metadata needs. In particular, you may not find an appropriate vocabulary to represent your information.

Interesting facts about RDFa:
eRDF and RDFa allow you to work with any RDF or OWL vocabulary, and create your own vocabulary or reuse existing ones. eRDF is a subset of the full RDF model; for example, you can only make statements about the current page. RDFa offers all the features of RDF, making it the most complex of the three formalisms but also the most powerful one.


Source:
http://www.google.com/support/webmasters/bin/answer.py?answer=176035

Monday, March 22, 2010

JDK 7 version
1. Platform modular
- Performance
- Scalable down
- Modular of code

2. JSR 292 - Dynamic byte code
Productive platform

3. JSR 203

4. File system API

5. Hotspot VM

6. Parallel array stuff

7.


https://channelsun.sun.com/media/show/15028
https://ch1blogs.cognizant.com/blogs/167603/2010/02/14/greasemonkey/
https://ch1blogs.cognizant.com/blogs/133669/2010/03/12/top-posts-ch1blogs-february-2010/

Remove the content item 85956552, 80939467,61158002,83912887 - remove targets,
Remove the content item 86653947, 86654262, 86654757 , 87135412 ,
Remove targets 87155517
Remove related items 86654262,87223452,87221242 sent from changed
Removed category 52007552,52519092 ,83925392, 80939967

Sunday, February 21, 2010

Every morning, when the sun

Every morning, when the sun rises in the east, a deer awakens knowing it must run faster than the fastest lion or it will be eaten. Every morning a lion awakens knowing it must outrun the slowest deer or it will starve. It matters not whether you are a deer or a lion, when the sun rises in the east, you had better be running.