Comments
paul.nowak wrote: Matt, thanks for the comments. I made an error on the version of Plone. It's 2.5 Plone running on Zope 2.9x. In regards to the additional products, we have a skin installed and we have a product that we had custom developed for us that connects to a PostgreSQL database. We've looked at slow PostgreSQL queries causing problems and have not been able to find an issue. We've also tested for the case where the PostgreSQL server is down and have not been able to create an issue. We therefor...
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


Secrets Of The Masters: Core Java Job Interview Questions
JDJ Enterprise Editor Yakov Fain Offers 30 Core Java Questions You Might Expect During Job Interviews

JDJ's Enterprise Editor, Yakov Fain (pictured) writes: If you are planning to hit the job market,  you may need to refresh some of the Java basic terms and techniques to prepare yourself for a technical interview. Let me offer you some of the core Java questions that you might expect during the interviews. 

For  most questions  I’ve provided only  short  answers to encourage further research.  I have included only  questions for mid (*) and senior level (**) Java developers. These sample questions could also become handy for people who need to interview Java developers (see also the article "Interviewing Enterprise Java Developers").

Disclaimer. This article has been originally published three or four years ago, hundreds of thousands Java developers have read it, but I still use some of these questions while interviewing Java developers. Guess what? Every other Java developer doesn't now the answers to some of them.

30 Java Interview Questions

* Q1. How could Java classes direct program messages to the system console, but error messages, say to a file?

A. The class System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default, they both point at the system console. This how the standard output could be re-directed:

Stream st = new Stream(new FileOutputStream("output.txt")); System.setErr(st); System.setOut(st);

* Q2. What's the difference between an interface and an abstract class?

A. An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.

* Q3. Why would you use a synchronized block vs. synchronized method?

A. Synchronized blocks place locks for shorter periods than synchronized methods.

* Q4. Explain the usage of the keyword transient?

A. This keyword indicates that the value of this member variable does not have to be serialized with the object. When the class will be de-serialized, this variable will be initialized with a default value of its data type (i.e. zero for integers).

* Q5. How can you force garbage collection?

A. You can't force GC, but could request it by calling System.gc(). JVM does not guarantee that GC will be started immediately.

* Q6. How do you know if an explicit object casting is needed?

A. If you assign a superclass object to a variable of a subclass's data type, you need to do explicit casting. For example:

Object a; Customer b; b = (Customer) a;

When you assign a subclass to a variable having a supeclass type, the casting is performed automatically.

* Q7. What's the difference between the methods sleep() and wait()

A. The code sleep(1000); puts thread aside for exactly one second. The code wait(1000), causes a wait of up to one second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread.

* Q8. Can you write a Java class that could be used both as an applet as well as an application?

A. Yes. Add a main() method to the applet.

* Q9. What's the difference between constructors and other methods?

A. Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

* Q10. Can you call one constructor from another if a class has multiple constructors

A. Yes. Use this() syntax.

* Q11. Explain the usage of Java packages.

A. This is a way to organize files when a project consists of multiple modules. It also helps resolve naming conflicts when different packages have classes with the same names. Packages access level also allows you to protect data from being used by the non-authorized classes.

* Q12. If a class is located in a package, what do you need to change in the OS environment to be able to use it?

A. You need to add a directory or a jar file that contains the package directories to the CLASSPATH environment variable. Let's say a class Employee belongs to a package com.xyz.hr; and is located in the file c:\dev\com\xyz\hr\Employee.java. In this case, you'd need to add c:\dev to the variable CLASSPATH. If this class contains the method main(), you could test it from a command prompt window as follows:

c:\>java com.xyz.hr.Employee

* Q13. What's the difference between J2SDK 1.5 and J2SDK 5.0?

A.There's no difference, Sun Microsystems just re-branded this version.

* Q14. What would you use to compare two String variables - the operator == or the method equals()?

A. I'd use the method equals() to compare the values of the Strings and the == to check if two variables point at the same instance of a String object.

* Q15. Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written?

A. Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first.

* Q16. Can an inner class declared inside of a method access local variables of this method?

A. It's possible if these variables are final.

* Q17. What can go wrong if you replace && with & in the following code:

String a=null; if (a!=null && a.length()>10) {...}

A. A single ampersand here would lead to a NullPointerException.

* Q18. What's the main difference between a Vector and an ArrayList

A. Java Vector class is internally synchronized and ArrayList is not.

* Q19. When should the method invokeLater()be used?

A. This method is used to ensure that Swing components are updated through the event-dispatching thread.

* Q20. How can a subclass call a method or a constructor defined in a superclass?

A. Use the following syntax: super.myMethod(); To call a constructor of the superclass, just write super(); in the first line of the subclass's constructor.

About Yakov Fain
Yakov Fain is a Managing Director of Farata Systems, consulting, training and product company. He has authored several Java books, dozens of technical articles. SYS-CON Books released his latest co-authored book , Rich Internet Applications with Adobe Flex and Java: Secrets of the Masters in Spring 2007. Sun Microsystems has nominated and awarded Yakov with the title Java Champion. He leads the Princeton Java Users Group. He is an Adobe Certified Flex Instructor. Currently Yakov works on the book for O'Reilly "Enterprise Application Development with Flex". He twits at twitter.com/yfain.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 12

A message to all,interview questions given here can be generic ONLY.Its not like for 2+ years,4+ years etc.It purely depends on the company and the role for which you are interviewed.Some of the interview questions i faced recently.I was able to clear all the theoretically related so they asked me by giving a scenario.

1. You need to read all the details from say.. www.yahoo.com/index.html, save it in a file in yor local PC. What API will you use in Java and what method??
2. You are saving a set of employee names and their salaries in a HashMap like that.. How will you sort them in descending order based on the salary?
This can be done by implementing the comparator interface.

If you need further information,drop a mail 2 graghuu@gmail.com

Cheers,
Raghu

Hi,
Could you please send me the interview questions in java,jsp,struts,jdbc,corejava for 1+ yers of experience as software engineer.

Thanks you,

Hi,
Could you please send me the interview questions in java,jsp,struts,jdbc,corejava for 2+ yers of experience as software engineer.

Thanks you,
Ashvini. S

these questions are stupid

these are moronic questions that idiots that don't know how to interview asks

lets get to some real world questions

Please send me expert level questions on jdbc 4.0

try http://www.java-interview.com for all the java related interview questions

please send me the interview questions in java,jsp,jdbc,corejava for 1+ yers of experience as a software engineer.
thanks you,

Thank you very much for such a good article.....as I'm in search of job this article would certainly be helpful for my preparation.

please send me the interview questions in java,jsp,jdbc,corejava for 1+ yers of experience as a software engineer.
thanks you,
sandeep

I have 1+ yrs experience of working in java.. please help me by sending the interview questions..

Data Migration/Conversion: It can be used to convert sql server tables into mysql tables

I need the type of questions asked in an interview for a job in java/j2ee foe 2+ years experience

Thanks

I need the type of questions asked in an interview for a job in java/j2ee with about 2 years experience.

Thanks

Hi,
Could you please send me the interview questions in java,jsp,struts,jdbc,corejava for 2+ yers of experience as software engineer.
Thanks you,
Archana.

I have acquired abt 4-5yrs of Java/J2EE exp and will be attending an interview in the States...Could you pls let me know on what are the tips that I need and pls help me with some questions that they will ask me?


Feedback Pages:


Your Feedback
Raghu wrote: A message to all,interview questions given here can be generic ONLY.Its not like for 2+ years,4+ years etc.It purely depends on the company and the role for which you are interviewed.Some of the interview questions i faced recently.I was able to clear all the theoretically related so they asked me by giving a scenario. 1. You need to read all the details from say.. www.yahoo.com/index.html, save it in a file in yor local PC. What API will you use in Java and what method?? 2. You are saving a set of employee names and their salaries in a HashMap like that.. How will you sort them in descending order based on the salary? This can be done by implementing the comparator interface. If you need further information,drop a mail 2 graghuu@gmail.com Cheers, Raghu
aruna wrote: Hi, Could you please send me the interview questions in java,jsp,struts,jdbc,corejava for 1+ yers of experience as software engineer. Thanks you,
Ashvini wrote: Hi, Could you please send me the interview questions in java,jsp,struts,jdbc,corejava for 2+ yers of experience as software engineer. Thanks you, Ashvini. S
. wrote: these questions are stupid these are moronic questions that idiots that don't know how to interview asks lets get to some real world questions
deepa wrote: Please send me expert level questions on jdbc 4.0
sandeep wrote: try http://www.java-interview.com for all the java related interview questions
shikha wrote: please send me the interview questions in java,jsp,jdbc,corejava for 1+ yers of experience as a software engineer. thanks you,
sreekanth wrote: Thank you very much for such a good article.....as I'm in search of job this article would certainly be helpful for my preparation.
sandeep wrote: please send me the interview questions in java,jsp,jdbc,corejava for 1+ yers of experience as a software engineer. thanks you, sandeep
siddharth wrote: I have 1+ yrs experience of working in java.. please help me by sending the interview questions..
varun wrote: Data Migration/Conversion: It can be used to convert sql server tables into mysql tables
rajyalakshmi.M wrote: I need the type of questions asked in an interview for a job in java/j2ee foe 2+ years experience Thanks
Ranjani wrote: I need the type of questions asked in an interview for a job in java/j2ee with about 2 years experience. Thanks
archana wrote: Hi, Could you please send me the interview questions in java,jsp,struts,jdbc,corejava for 2+ yers of experience as software engineer. Thanks you, Archana.
sony wrote: I have acquired abt 4-5yrs of Java/J2EE exp and will be attending an interview in the States...Could you pls let me know on what are the tips that I need and pls help me with some questions that they will ask me?
srinivas wrote: plz send j2ee interview questions with 2+ exp
Mitesh wrote: I need to Prepare for Internship as Java Programmer
VANI SARIN (Recruiter at GE Healthcare) wrote: GE Healthcare is hiring Sr. J2EE Developer and Web Client Developers with Ajax and or googleweb toolkit. Please visit www.gecareers.com and enter job #s 756156 and 756161
vani wrote: can u plz send me 2+yrs core,jsp,servlet,jddbc questions
nirupama reddy wrote: hi,plz send me 1+ yrs core,adv,servlets,jsps questions
Enterprise Open Source Magazine Latest Stories . . .
This is a deal that has been around for all of this year, and I know the NYC-based guy charged with pulling the technical pieces together. He has been looking at software platforms for months and separating contenders from pretenders based on the criteria he's established. To my knowle...
3Leaf Systems, the well-funded start-up, dropped its fig leaf Tuesday and took a running jump into the pools of memory, I/O and cache that it can construct and deconstruct at will based on the application, creating scale-up shared-memory SMP systems the likes of mainframes, proprietary...
Funambol, a provider of open source mobile cloud sync and push email for billions of phones, today announced it has acquired Zapatec, Inc., a leader of AJAX web 2.0 frameworks. The acquisition enables Funambol to uniquely address the industry pervasive device fragmentation challenge th...
Plone and Drupal are two leading open source Content Management Systems (CMS). Both were recognized in the 2009 Open Source CMS awards, run by Packt Publishing. Both also have large installed bases and large developer communities. This is made evident by some quick searching on Googl...
SOASTA, a provider cloud testing, today announced that performance engineers can now build web application tests in Apache JMeter, the most popular open source load testing tool, and run them in SOASTA's Global Test Cloud. Deploying JMeter tests to the Cloud has been a complex, time-co...
Yahoo! Inc. (Nasdaq:YHOO), a leading global Internet company, took its second major step in five months towards open-source cloud computing today, debuting an open source version of Traffic Server, a high performance application server for builders of cloud services. Traffic Server ena...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE