News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Java &J2ee Interview Questions

Started by kavee, Jan 24, 2009, 01:05 AM

Previous topic - Next topic

kavee

A Transient variable is

  A) the one which does not serialize its value.

B) variable that can change its value.

C) the one whose value is constant.

D) the variable

   

2)What is Iterator?
A) is a variable.

B) is an interface.

C) is a Class.

D is a method.



 

3)class PrintTest{

public static void main(String[] args) {

double d=222.4578;
System.out.printf("% .2f",d);

}

}

A) Throws IllegalFormatConversionException
B) Prints 222.46
C) Prints 222.45
D) Prints .2224578


 

4) What is the result of compiling and running the following code, assuming that the file bb.txt does not exist?

class WriterTest{

public static void main(String[] args) throws IOException{

Writer w=new BufferedWriter(new FileWriter("bb.txt")); // Line1
w.write(1); // Line2
w.close();

}

}


A.Compiler error
B.FileNotFoundException thrown at line 1
C.IOException thrown at line 2
D.None of these

   

5) How can I multiply two double numbers without loss of precision?

  A. wrap the doubles in a   Integer object.

B. using roundoff operations in doubles

C. wrap the doubles in a BigDecimal object.

D. misses floating point values.

 



6) How you can force the garbage collection?


A. By using the method finalize().

B. Garbage collection is automatic process and can't be forced.

C. Using System.gc().

D. Using Runtime.gc().



 

7) Which are not Access Specifiers in Java given below?


i. Volatile.   ii. Private. iii. Protected. iv. Transient.

  A. i and ii.

B. ii and iv.

C. i and iv.

D. iii and iv.

How do threads communicate with each other?


A. wait().

B. notify().

C. notifyAll().

D. all the above.

E. none of the above.





16) Which class provides the capability to implement a growable array of objects?
A. Array.

B. Vector.

C. Object.

D. None of the above.

E. All the above.



 

17) How many bits are used to represent Unicode?

  A. 8 bits.

B. 16 bits.

C. 32 bits.

D. 4 bytes.





18) Which class is the superclass for every class.
A. Collection.

B. Array.

C. Object.

D. Util.



 

19) Identify the advantages of JSP over Servlet.
A. Embedding of Java code in HTML pages
B. Platform independence
C. Creation of database-driven Web applications
D. Server-side programming capabilities


 

20) Which is not an implicit Object available in the JSP Page?


A. out.

B. session.

C. printwriter.

D. application.



 

21) Which life-cycle methods of JSP cannot be overridden?


A. jspInit().

B. jspService().

C. jspDestroy().

D. none of the above.

E. all the above.


22) Which of the following are   the call back methods in Session bean?
  A. ejbCreate().

B. ejbPassivate().

C. ejbActivate().

D. all the above.

E. none of the above.


kavee

What is difference between Application Server and Web
Server?

Answer
In web server we can run onyy servlet and jsp but in
application server we can run servlet,jsp and ejb..
WEB-SERVER-Tomcat,resin
App-WEBLOGIC,JBOSS


 
 
Question 2 What is IOC in spring?

Answer 

IOC(Inversion of control)is a technique that allows object
configuration to be moved out of code and into a
configuration file. With Spring IOC, this is typically done
with an XML file.
The steps to use Spring IOC are:

1. Write Java Bean classes, with getter and setter methods
for each property to be configured by Spring.
2. Create an XML file that describes the Java Beans to be
configured.
3. Use an XMLBeanFactory to create configured beans. There
are other ways to read bean descriptions, but using an
XmlBeanFactory is more common.
   
 
 
Question 3
What is the difference between Eclipse and MyEclipse?

Answer  Eclipse needs MyEclipse plugable source
But MyEclipse did not required any plugable source

 
 


   
Question 4
Difference between Spring framework and Struts framework?
 
Answer  STRUTS :
1.Struts framework is based on MVC pattern to develop web
applications and which is used to generate integration logic
dynamically.
2.Struts allows only JSP as a view component.

SPRING:
1.Spring framework is used to develop enterprise applications.
2.Spring framework not only allows JSPs but also other views
such as Velocity,Freemaker etc.,
3.Spring f/w consists of 6 modules which are alternatives
for existing J2ee Technologies.


 
 
Answer  struts framework is a mvc pattern. spring framework is a
mvc pattern and other patterns also include in this.
   
Answer  Spring framework provides dependency injection.Which is
alternative to EJB.Spring framework provides many features
like velocity,Hibernate,Ibatis,PDF,Excel
views,JDO,Interceptors,web services.Whic can be built in
Spring framework very easily.It is a J2EE application
framewrok.


Struts is MVC pattern provides limited features.For
distributed applications it will have to use EJB.
    0  Yugandhar
[Java] 
 
 
Answer  Struts is a web framework which can be used to develop web
applications using MVC pattern. We have to hard code to use
applications like hibernate, jdbc, etc.

Spring is an application framework in which spring MVC is
one of the modules of spring framework. Spring uses the
concept of IOC/DI where the objects are not hard coded in
java but they are injected using construtor/setter
injection. We can use hibernate, jdbc, etc,...with spring
without hard coding in application as spring supports
classes hibernate, jdbc, and many more. This is very little
to say about spring. There are many features to be known.
    0  Anand

 
 
Question 5
What is need of DAO? Write one simple DAO example?

Answer  DAO: Data Access Object. here the main concept of DAO is to
communicate with the database. DAO mainly contains
1.) DAOFactory: this specifies which kind of database
(wether MySQL or ORACLE or MSSQL etc...).

2.) SQLFactory: which extends the DAOFactory. Here we do
all the connection stuffs.deciding te driver, hostname,
URL, username, password etc and also getting the Connection
object.

3.) AdminDAO: this is a interface where we declare all the
methods which we need in our application to perform all the
database related operation.

4.) SQLAdminFactory: this implements the AdminDAO
interface, all its method. this also gets the connection
from SQLFactory.

5.) TransactionControlDAO: here we keep the commit and
roolback methods.

if required...
6) ConnectionConstant: in this file we can mention the file
name (.properties file) where we keep the connection
detals, like hostname, username, password, etc...
   
 
Question 6
What is the use of log4j and how to make use of
that in a application?

Answer  log4j can be used for writing the log messages to various
kinds of destinations like a file, database, console etc...

It is always advisable to use some sort of logging API to
generate the log messages.the log messages helps the end
user as well as the developer of the application, to kow
about what the application has done and why the application
has failed, etc...

It is developed by Apache and this is used as part of
various products like hibernate, struts, strings etc...
 

 
 
Question 7 what is difference between vector and arraylist?.


Answer  vector is synchronized . collection object and variable
slow acess. muntable
array list is never snchronized. collection variable fast
acess


 
 
Answer  Vector is synchronized and compare to array list this slow
access, by defaulst the vector is 10,this is legacy class
Where as arraylist is unsynchronized and fast random
access,in arraylist there is no default size automatically
it is growable once the object is created it will be

 
 
Question  httt method
Rank  Answer Posted By   

Answer  doget,dopost,doput,dohead,dooption,dodelete,dotrace
doget method default method.

Answer  doGet, if the servlet supports HTTP GET requests
doPost, for HTTP POST requests
doPut, for HTTP PUT requests
doDelete, for HTTP DELETE requests
init and destroy, to manage resources that are held for the
life of the servlet
getServletInfo, which the servlet uses to provide
information about itself
   
 
 
Question 8 What is a constructor?

Answer  A constructor is one which is used to initialize the
instance variables of an object.


 
 
Answer  Guarrented intilization of instance variables of an object.
 

 
 
Question 9 which book is the best for preparing for SCWCD 1.5

Answer  SCWCD1.5 by Kathy Sierra is the Best Book


 
 
Answer  Head First Servlets & JSP
 
 
 
Answer  if you want to read just for exam perspective then read
only SCWCD1.5 by Kathy Sierra and if you want to increase
your knowledge then first read Head First Servlets & JSP