Natraj Interviews
Natraj Interviews
Natraj Interviews
HashSet
It stores grouped data.
It implements Map
It implements Set.
Sleep(-)
Do
StringBuffer
It is mutable.
Iterator<string> itr=set.iterator();
while(itr.hasNext()){
//true.false
String empkeys=itr.next(); //for keys
String empvalnames=hm.get(empkeys); //gives values by taking keys.
System.out.println(empname+empvalnames+empid+empkeys);
}
8) What are thread states?
i) Start: Thread thread=new Thread();
ii) Runnable: looking for its turn to be picked for execution by the Thread Schedular based
on thead priorities. (setPriority())
iii) Running: The Processor is actively executing the thread code. It runs until it becomes
blocked, or voluntarily gives up its turn with Thread.yield().
Because of Context Switching overhead, yield() should not be used very
frequently.
iv) Waiting: A thread is in a blocked state while it waits for some external processing such
as file I/O to finish.
Sleepingsleep(): Java threads are forcibly put to sleep (suspended) with this overloaded method.
Thread.sleep(milliseconds); Thread.sleep(milliseconds,nanoseconds);
Blocking on I/O: Will move to runnable after I/O condition like reading bytes of data etc changes.
Blocked on Synchronization: will move to Runnable when a Lock is acquired.
v) Dead: The thread is finished working.
How to avoid Deadlock:
1) Avoid a thread holding multiple locks---If no thread attempts to hold more than one lock, then no deadlock occurs.
2) Reordering lock acquisition:-If we require threads to always
acquire locks in a particular order, then no deadlock occurs.
2.Oracle Corporation:-
15-11-2009
9) What are differences b/w concrete,abstract classes and interface & they are given?
Concrete class: A class of only Concrete methods is called Concrete Class.
For this, object instantiation is possible directly.
A class can extends one class and implements many interfaces.
Abstract class:
Interface:
* It allows constructor.
This class cant be instantiated directly.
10)
11)
12)
Iterator iterator=list.iterator();
while(iterator.hasNext()){
String str=(String)itr.next();
S.o.p(string);
}
}
13) What are versions of your current project technologies?
Java 5.0; Servlets 2.4, Jsp 2.0; struts 1.3.4 ; spring 2.0; Hibernate 3.2, Oracle 9i. weblogic 8.5.
14) What is Quality?
It is a Measure of excellence.
state of being free from defects, deficiencies, and significant variations.
A product or service that bears its ability to satisfy stated or implied needs."
15) Can I take a class as private?
Yes, but it is declare to inner class, not to outer class.
If we are declaring "private" to outer class nothing can be
accessed from that outer class to inner class.
16)
3.Date:17-11-2009- Telephonic
22) What Design Patterns are you using in your project?
i) MVCseparates roles using different technologies,
ii) Singleton Java classTo satisfy the Servlet Specification, a servlet must be a Single
Instance multiple thread component.
iii) Front Controller A Servlet developed as FrontController can traps only the requests.
iv) D.T.O/ V.OData Transfer Object/Value object is there to send huge amount of data
from one lalyer to another layer.
It avoids Network Round trips.
v) IOC/Dependency Injection F/w s/w or container can automatically instantiates the
objects implicitly and injects the dependent data to that object.
vi) Factory method It wont allows object instantiation from out-side of the calss.
vii) View Helper It is there to develop a JSP without Java code so that readability,
re-usability will become easy.
23) What is Singleton Java class & its importance?
A Java class that allows to create only one object per JVM is called Singleton Java class.
Ex: In Struts f/w, the ActionServlet is a Singleton Java class.
Use: Instead of creating multiple objects for a Java class having same data, it is recommended
to create only one object & use it for multiple no. of times.
24) What are the differences b/w perform() & execute()?
perform() is an deprecated method.
25) What are the drawbacks of Struts? Is it MVC-I or II? Struts is MVC-II
1) Struts 1.x components are API dependent. Because Action & FormBean classes must
extend from the Struts 1.x APIs pre-defined classes.
2) Since applications are API dependent hence their Unit testing becomes complex.
3) Struts allows only JSP technology in developing View-layer components.
4) Struts application Debugging is quite complex.
5) Struts gives no built-in AJAX support. (for asynchronous communication)
Note:
In Struts 1.x, the form that comes on the Browser-Window can be displayed
under no control of F/W s/w & Action class.
26) What are the differences b/w struts, spring and hibernate?
Struts: allows to develop only webapplications and
it cant support POJO/POJI model programming.
Spring: is useful in developing all types of Java applications and
support POJO/POJI model programming.
vi) native-------------method.
vii) volatile-----------variable
viii) strict fp-----------variable
30) Which JSP tag is used to display error validation?
In Source page:
<%@page errorPage=error-page-name.jsp>
In Error page:
<%@page isErrorPage=true>
31) What are the roles of EJBContainer ?
An EJB container is the world in which an EJB bean lives.
The container services requests from the EJB, forwards requests from the client to the EJB, and interacts
with the EJB server.
The container provider must provide transaction support, security and persistence to beans.
It is also responsible for running the beans and for ensuring that the beans are protected from the outside
world.
32) If double is added to String then what is the result?
Double + String=String
4.CrimsonLogic-Murugeshpalya-kemfort- 18-11-2009
33) What is Ant? What is its use
Ant is a tool that is used to build war, compilation, deploy.
34) What is log4j? What is its functionality?
Log4j is a tool used to display logger messages on a file/console.
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
< appender name="FILE" class="org.apache.log4j.FileAppender">
logger.debug("Hi");
logger.info("Test Log");
logger.error()
Logger logger = Logger.getLogger(SampleLogtest.class);
35) What are the functions of service()?
protected void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException, java.io.IOException
Receives standard HTTP requests from the public service method and dispatches them to the doXXX methods
defined in this class. This method is an HTTP-specific version of the
public void service(ServletRequest req, ServletResponse res)
throws ServletException, java.io.IOException
Dispatches client requests to the protected service method.
There's no need to override this method.
36) How do we get the container related information?
40) What is Hidden variable and give its snipplet HTML code?
<input type="hidden" id="age" name="age" value="23" />
<input type="hidden" id="DOB" name="DOB" value="01/01/70" />
<input type="hidden" id="admin" name="admin" value="1" />
41) How do you forward Servlet1 request to Servlet2?
ServletContext sc=getServletContext();
RequestDispatcher rd =sc.getRequestDispatcher(/s2url); // or html file name
rd.forward(req,resp);
(or) rd.include(req,resp);
5. Telephonic Interview:
23-11-2009.. MindTree
Vector
Do
Legacy Collection F/W class
Synchronized
Non-serialized
Configuration file
51) What are the differences b/w Struts 1.x & Struts 2.x?
method/variable.
InterruptedException,---when two or more threads try to share same Resource(wait() and join())
NoSuchFieldException ---when we access the undeclared variable
NoSuchMethodException---when we invoke the undeclared method.
InstantiationException---when we try to create object for a abstract/interface
Unchecked Exceptions deal runtime errors.
Ex: ArithmeticException,
ArrayOutOfBoundsException,
NullPointerException
64) Differenc b/w Exception & Error?
Date: 08-01-2010.
Magna consultancy.
Criteria criteria=session.createCriteria(EmpBean.class);
// select * from Employee where eid between 100 and 200 and firstname in (raja,ramana));
Condition: 1
criteria=criteria.add(Expression.between(no,new Integer(100)),new Integer(200));
Condition: 2
criteria=criteria.add(Expression.in(fname,new String []{raja,ramana} )));
List l=ct.list();
// retrieves more selected records
for(int x=0;x<l.size();x++){
EmpBean emp=(EmpBean) l.get(x);
S.o.p(emp.getNo()+\t+emp.getFname()+\t+emp.getLname()+\t+emp.getEmail());
90) What is Hibernate configuration file?
HB dialect, DB Driver class, Driver class URL, Username, Password.
91) Why the people using frameworks?
92) What is POJO & POJI model programming?
The programming with no api dependent classes/interfaces
93) What is Caching mechanism?
To minimize n/w round trips.
Session is default and
SessionFactory explicitly configured.
94) Do you know restriction and expression?
Expression.between()
Expression.in()
95) Do you know algorithms like increment , sequence, hilo.?
96) What are the different Scopes in JSP?
request, page, session, application
97) How to disable Cache ?
<% resp.setHeader(cache-control, no-cache);%>
(<meta http-equiv=cache-control content=no-cache>
<%resp.setHeader(pragma,no-cache);%> //http1.0
OR
<meta http-equiv=pragma content=no-cache>)
98) What is default Scope in JSP?
page
99) How to configure a JavaBean in JSP?
<jsp:useBean>
Date: 23-01-2010. Saturday. CSC India pvt ltd. Domlur Flyover.(333 from majestic)
111)How Java is Platform Independent?
.class filebyte code
112) What is Association and Composition?
113) How can I achieve multiple inheritance in Java without using inheritance?
114) Write the code for a class which implements the Runnable interface?
Public class RunClass implement Runnable{
------------------------public void run(){
--------}
Runnable r=new RunClass();
Thread thr=new Thread(r);
thr.start();
115) There are m1(), m2() methods and t1,t2 threads.
How can t1 execute m1() and t2 executes m2()?
116) What is join()?
When a current thread wants to finish its complete execution and allow the second thread to do
its execution then first thread must invoke this join();
116) How do you make the variables applicable to the whole application in JSP?
--Store that variable in session scope (I think)
117) How do you configure one to many association in Hibernate?
<set> and <key> and <one-to-many>
<set name="address">
<key column="emp_id"/>
<one-to-many class="EmpAddress"/>
</set>
118) What are types of Beans in EJB?
Session Bean---Stateless, Statefull
Entity Bean
MessageDriven Bean
119)
class A{
class B extends A{
i=10;
i=20 ;
printText(){
printText(){
s.o.p(from A); s.o.p(from B);
class D{
p s v m(){
A a=new B();
a.printText(); // from B
}
s.o.p( +a.i); } // i=10
122) What is InterruptedException?
When two or more threads try to access same object simultaneously, then this exception
occurs. Join(), wait(), notify() ,notifyAll() throws InterruptedException.
123) What Design patterns do you know?
MVC, Singleton class, Factory , FrontController, DAO class, D.T.O/V.O
124) What an Interface allows in its inside?
Abstract methods, constants, interface.
125) Can I define a class inside an Interface?
Yes
126) What is HB? What are its files.
It is an ORM tool that is there to develop DB independent persistence logic.
Hibernate-config.xml, Hibernate-mapping.xml, pojo class
127) How to integrate HB with Spring?
The DAO implementation class of spring must extends HibernateDAOSupport and
implements DAO interface.
128) How to integrate Struts with Spring?
ContextLoaderPlugIn and DeligationActionProxy configure in Struts config file
And Action classes configure in applicationContext.xml
129) What are the differences b/w BeanFactory and ApplicationContext?
BeanFactory (I) container
to develop spring core
applications.
ApplicationContext (I)
It is an advanced & extended for BeanFactory.
It gives full fledged spring features support like;
i) Bean property values can be collected from
outside properties file.
ii) gives support for Pre-Initialization of Beans.
iii) text messages can be collected from
outside property files to give support for i18n.
iv) allows to work with EventHandling through Listeners.
Event
Listener
EventHandling
methods (public void
ServletRequest ServletRequestEvent(sre) ServletRequestListener requestInitialized(sre)
requestDestroyed(sre)
ServletContext ServletContextEvent(sce) ServletContextListener
contextInitialized(sce)
contextDestroyed(sce)
HttpSession
sessionCreated(hse)
sessionDestroyed(hse)
HttpSessionEvent (hse)
HttpSessionListener
GET
1) It is a default Http request method
POST
Not a default method.
Session Tracking: It is a technique by which the client data can be remembered across
the multiple requests given by a client during a Session.
1) Hidden Form Fields
2) Http Cookies
3) HttpSession with Cookies
4) HttpSession with URL-rewriting.(best)
147) How to handle multiple submit buttons in a HTML form?
<input type=submit name=s1 value=add> </th>
<input type=submit name=s1 value=delete> </th>
<input type=submit name=s1 value=modify> </th>
Code for accessing the above data in Servlet.
String cap=request.getParameter(s1);
if(cap.equals(add)) {
---------- }
elseif(cap.equals(delete)) {
------------- }
else(cap.equals(modify)) {
------------ }
HoneyWell---from Banshankari 500L, Intel Stop, Dhevarabesinahalli---2.00pm15 mints
1) What you write to open a window?
Window.open(); in Javascript
<a href="javascript:;" onClick="mm_openbrwindow('Mypage.html','','width=800,
height=600, scrollbars=no')">MyPage</a>
newwindow=window.open(url,'name','height=500,width=400,left=100,
top=100,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
148) Do you know CSS? What can I do with CSS?
CSS is a style language that defines layout of HTML documents. For example, CSS covers fonts, colours,
margins, lines, height, width, background images, advanced positions and many other things
149)What is the difference between CSS and HTML?
HTML is used to structure content. CSS is used for formatting structured content.
150) What are the uses with Hibernate?
i) It allows to develop DB independent query language like HQL.
ii) It supports POJO/POJI model programming.
iii) Any Java/J2EE can access HB persistence logic.
iv) It supports to call all Procedures & Functions of PL/SQL programming.
v) The result after SELECT operation, by default, is Serializable.
Enter PIN
Valid PIN
Not Valid
Check Bal
available Bal
Not available
Withdraw
process
stop
159) What is Synchronization?
The process of allowing only one thread among n no. of threads into a Sharable Resource
to perform Read & Write operations.
160) What are the primitives?
byte, int, short, long, float, double, char, booleanlocal variables.
161) What happens when we store primitives to Collections?
162) What are the Wrapper class objects?
The primitives are not allowed to store inside the collections. So, they will be converted into
Wrapper class objects using their respective wrapper classes.
163) What is the difference between Apache Server & Tomcat Server?
Apache/ Apache HTTP Server, is an established standard in the online distribution of website services, which
gave the initial boost for the expansion of the W.W.W.
. It is an open-source web server platform, which guarantees the online availability of the majority of the
websites active today.
The server is aimed at serving a great deal of widely popular modern web platforms/operating systems such as
Unix, Windows, Linux, Solaris, Novell NetWare, FreeBSD, Mac OS X, Microsoft Windows, OS/2, etc.
164) What is an ApplicationServer?
165)
Using dialect, Hibernate knows the type of DB & its version to which it will connected.
180) How do you map HB Pojo class with Table?
<hibernate-mapping default-cascade="none" default-access="property" defaultlazy="true"
auto-import="true">
<class name="CustomerOrder" table="CustomerOrder" mutable="true"
polymorphism="implicit" dynamic-update="false" dynamic-insert="false" selectbefore-update="false" optimistic-lock="version">
<composite-id name="orderId" class="OrderId" mapped="false" unsavedvalue="undefined">
<key-property name="customerId" column="customer_id" />
<key-property name="orderTime" column="order_time" />
</composite-id>
<property name="orderDescription" unique="false" optimistic-lock="true" lazy="false"
generated="never" />
</class>
</hibernate-mapping>
181) In HashMap, how can I locate a particular key?
Hm.containsKey(3); Hm.containsValue(key);
182) Difference b/w SVN(Sub VersioN) & VSS (Visual Source Safe--microsoft)?
Usually team members do all of their work separately, in their own working copies and need to share their
work. This is done via a Subversion repository. Syncro SVN Client supports the versions 1.3, 1.4, 1.5 and
1.6 of the SVN repository format
1. Expansion. The number of programmers doubled and we didn't want to fork out for the extra VSS
licenses
2. Bugs. VSS is good at maintaining the latest version of a file, but histories often got corrupted.
3. More bugs. The checking/recovery tools were useless as they started crashing when the database got
very large.
183) What is Servlet Chaining?
Servlet Chaining is a method of processing the request using multiple servlets as a chain.
184) What is the use of DyanaActionForm?
It allows Declarative data population that avoids recompilation.
185) prototype of execute(-,-,-,-)?
public ActionForward execute(ActionMapping am,
ActionForm af,
HttpServletRequest req,
HttpServletResponse resp)
186) Difference b/w ActionForm, DynaActionForm and DynaValidatorForm?
All three are JavaBean Classes that can maintain the session state for web application.
The ActionForm object is automatically populated on the server side with data
entered from a form on the client side.
An ActionForm/DynaValidateForm can have getter(),Setter(), reset() and the validate() methods that can
be defined in our ActionForm or in Action class itself.
*
Here comes the DynaActionForm to rescue. It allows properites to be specified in Struts-cofig.xml file there
by avoiding the recompilation of the code.
Also there is no need to have a Form Bean for every page that had getter and
setter method for each of the field on the page.
This is how it can be declared in struts config file:
<form-beans>
<form-bean name="employeeForm"
type="org.apache.struts.action.DynaActionForm">
<form-property name="fname" type="java.lang.String"/>
</form-bean>
</form-beans>
187) How the DispatchAction knows, when it is pointed by multiple JSPs,
which jsp request execute which DispatchAction method to process the request by
executing the B.logic?
JSP sends the method name along with the request as
additional request parameter to DispatchAction.
function=insert, update, delete.(methods in OurAction)
Take a parameter attribute that represents all the methods of DispathAction class that
configured in Stuts-Config.xml using <action-mappings>.
Take the different JSP forms where property=parameter value and value=method-name
under the hidden tag.(<input name= type= value= >)
<action-mappings>
<action path=/controller1
name=bean
type=OurAction //name of the DispathAction
parameter=function scope=request/>
Add.jsp: <html: hidden property=function value=insert>
Modify.jsp: <html: hidden property=function value=update>
Delete.jsp: <html: hidden property=function value=delete>
Keane India Ltd, Basavanagudi, South End Circle. Banshankari--190) What is Expression tag in JSP?
It is used to
i)
evaluate a Java expression & sends that result to Browser-window. <%=a+b;%>
ii)
display the variable values on the Browser-window. <% int a=10;%> <% =a %>
iii)
call both pre-defined & user-defined methods.
<%=sum(10,20)%> , <%=raja.length()%>
iv)
instantiates java classes & to display the default data of the object.
Function
212) What tool are you using to write hundreds of fields for your project?
213) What code styles are you following in IDE?
214) Procedure to work with PreparedStatement in a Java application.
1). Prepare a query having positional/place holders/in parameters.ie.(?,?,?)
2). Send the query to DB s/w, make the query as pre-compiled query & represent
it through PreparedStatement.
3). Set the values for place-holders using setXXX(-,-).
4). Execute the query.
5). To execute the same query for multiple no. of times with same/different values,
repeat steps 3 & 4 for multiple times.
6). Close PreparedStatement object.