Java Interview Question Set
Java Interview Question Set
Join the DZone community and get the full member experience.Join For Free
Yet another set of Real Time Java Interview Questions
Industry : Leading Hospitality Company in US
Position : Jave / J2EE Developer
Type of Screening : Telephone
Date : 08/31/2013
This was a telephonic interview and the candidate was screened on the following sections.
Strong Java background including J2EE
Q: What effect does the key word “synchronized” have when used in a method declaration?
A: Ensures that at any time only one thread may run code within the method. (this is an extremely simplified explanation to a very complex topic and does not cover all cases)
Q: Describe the difference between a stateful and stateless session bean.
A: In a stateful session bean the state of the bean is maintained across multiple calls.
Expert knowledge of Struts framework including version 1.1 items
Q: How would you rename your struts-config.xml file?
A: Modify the “config” attribute in the web.xml
Q: Within an action, how do you forward a request to another action rather than a JSP.
A: Return a reference to an ActionForward defined in the struts config. The target ActionForward should reference the target action.
Q: What value is included in the URL parameter string to represent as unchecked checkbox named “mycheckbox” (nothing, no name, and no value)?
A: Nothing is included in the URL to represent an unchecked check box.
Expert knowledge of SQL
Q: What is the difference between “having” and “where” in a SQL statement?
A: The where clause is used to refine the results of the query based on the data being queried. Having, is used to filter the results of a query based on the value in a group by function such as sum, max or count (projection vs. aggregation)?
Q: Given a table called people with two columns, “name” and “age” write a query that would display a list of ages for all of the people named john sorted from oldest to youngest
A: select age from people where name = ‘john’ order by age desc
or select age from people where name = ‘john’ order by 1 desc
Q: Describe the difference between an inner and outer join.
A: In an outer join rows will be returned even without a matching row in the joined table based on the join criteria. An inner join will return the intersection of both tables based on the join criteria.
Expert knowledge of JDBC
Q: What components of a JDBC operation would fall within these three exception handling structures: try, catch, finally
A: try – obtain a DB connection, execute the query, retrieve the results
catch – log errors
finally – close connection (maybe wrapped in a another try catch)
Q: What types of JDBC statements will accept input parameters?
A: Prepared Statement and Callable Statement
Q: What is the difference in precision the java.util.Date and java.sql.Date?
A. java.util.Date includes time and java.sql.Date does not
Proficient in the use of XML & XSLT
Q: Are XML Element and Attribute names case sensitive?
Q: What is the difference between a well form and a valid XML document?
A: A well formed document conforms to XML standards, while a valid XML document must also conform to a defined XML schema.
Q: What is the difference between SAX and DOM xml parsing?
A: SAX is event driven and does not load all of the XML data into memory while DOM parses and loads the entire document into memory.
Working knowledge of Unix
Q: What command would you use to delete a directory and all files and directories it contains?
A: One of the follow:
rm -r [directory name]
rm -rf [directory name]
Q: How would you redirect the output of the ls command to a file?
A: ls > [file name]
Q: How do you grant the group owner of a file execute permission for the file?
A: chmod g+x
Q: Can more than one user simultaneously edit a single file stored in a CVS repository?
A: Yes, the C in CVS stands for concurrent.
Q: What is tag?
A: A name use to identify a revision of a group of cvs files.
Q: What is a revision?
A: This is the version number assigned to a single file.
Working knowledge of ANT
Q: What is ant?
A: Java based (platform independent) build utility
Q: What is a target in ANT?
A: A specific portion of and ANT file that can be executed
Q: How do you account for dependencies between ant targets?
A: Using the “depends” property in the target tag you can identify targets that must be executed prior to the target you are defining.
Q: Name two ant tasks use to build an enterprise web application.
A: Any two of the following- javac, jar, war, ear
Q: What is a fileset and what is it used for?
A: This tag is used to identify a group of files used as input to an ant task such as javac, copy, war, jar etc.
Q: If your java web application is not responding in production, what steps would you take to troubleshoot the issue?
A: Review server logs and application logs
Q: What if the logs do not indicate an error and the logs appear to have stopped writting?
A: Produce a thread dump
B: Review any monitoring or troubleshooting tool to check memory, db connection pools
C: Check server disk space and memory
Q: What is a commong cause for an issue liket this?
A: Hung aon a shared resource like DB connection pool
Q: How would you troubleshoot an out of memory issue?
A: Get a heap dump and analyse which objects are taking up memory and what has refernces to them
Use a profilieng tool like jprobe, exercise the code and review the profile to see what is consuming memory
Q: What is a thread dump?
A: Stack trace for every thread in the JVM. Used to look for the cause of waiting threads and other performance issues.
Published at DZone with permission of Jagadeesh Motamarri , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.