• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Good Java Interview Questions!

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I just now completed an interview with a company based in San Jose, California and I thought I could share some of the questions that I was asked. I think most of the questions listed here are very common and I have encountered them in many of my earlier interviews.
1) what are stored procedures? How is it useful.
2) differentiate between inner join and outer join?
3) when should finally block be used with a try catch block? what is finalize method?
4) write an algorithm to implement garbage collection efficiently?
5) what is the difference between ArrayList and regular arrays?
6) whats the difference between implementing a thread using Runnable interface and extending the Thread class? What are the benefits of one over the other.
6) what is delegation event model?
7) In an MVC architecture using Swing (Say JList) which takes the controller part?
It would be really beneficial for people to know the answers to these questions. I would appreciate it if the above questions are answered in this thread. I would also like people to submit their interview questions so that they can be answered and further discussed.
Regards,
Easwar Satrasala.
SCJP,
SCEA.
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eshwar,
Nice questions. Thanks for your post.
I am curious about which position are you applying while encounter these qtns.
 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1) what are stored procedures? How is it useful.


huh???

2) differentiate between inner join and outer join?


Double huh??? *2

) when should finally block be used with a try catch block? what is finalize method?


It should always be called to close connections, that would stay open if there was an exception,or if you want to be sure that some code will be execute, since finally is always called.
Java guarantee that finalize is always called before destroying an object.

4) write an algorithm to implement garbage collection efficiently?


I am really curious about the algorithm to implement garbage collection efficiently?

6) whats the difference between implementing a thread using Runnable interface and extending the Thread class? What are the benefits of one over the other.


If you extend the thread class, you just can't extend another class which is sometimes too bad!
Waiting for more explanation!
I would have get the job with my clear explanation, don't you think!
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to jobs discussions.
 
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good questions - except for 1 and 2 which are DB quesions. Thanks.
 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But if you are interviewing to work in an enterprise java environment, you should expect those kinds of questions.
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answers to

1) what are stored procedures? How is it useful.
2) differentiate between inner join and outer join?



1. A stored procedure is a set of statements/commands which reside in the database. The stored procedure is precompiled and saves the database the effort of parsing and compiling sql statements everytime a query is run. Each Database has it's own stored procedure language, usually a variant of C with a SQL preproceesor. Newer versions of db's support writing stored procs in Java and Perl too.
Before the advent of 3-tier/n-tier architecture it was pretty common for stored procs to implement the business logic( A lot of systems still do it). The biggest advantage is of course speed. Also certain kind of data manipulations are not achieved in SQL. Stored procs provide a mechanism to do these manipulations. Stored procs are also useful when you want to do Batch updates/exports/houseKeeping kind of stuff on the db. The overhead of a JDBC Connection may be significant in these cases.

2. An inner join is when you want to pick up rows only where the joined fields are equal
For e.g
Customer Table Order Table
---------------------------------------------
Cust Id Cust Name Cust Id Order No.
1 ABC 1 1
1 2
1 3
2 DEF
3 ghe 3 1
3 2
---------------------------------------------
An inner join on the Customer and Order will return records for cust id 1 and 3.
An outer join will return all records from Customer and records from order where they match (In this case all of them).
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eshwar,
I noticed that you are a SCEA. I was just wondering:
1) How useful do you think this has been in your job search?
2)How have you been finding the job market lately? Any sign that it is picking up?
Thanks in advance,
Daryl
 
Ranch Hand
Posts: 925
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have some interview questions also...
http://www.x-nt.com/interview.html
p.s. It looks like interview #2 are gonna offer me a job
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eshwar & Simon. I am sure your notes will help others. Wish you all the best in your job search.
[ March 29, 2002: Message edited by: Sunanda Miranda ]
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eshwar and Simon, thanks for your sharing with us in here. Good luck in your job hunting.
Yingtang
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
4) write an algorithm to implement garbage collection efficiently?
My answer: why?
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eashwar,
Thanks for the questions. Well the last 2 questions can u give me the answers.
Also, out of curioisity, did u get thru the interview and get the job ???
I am also seraching for a new one .. sending and sending, but all in vain...
Steffy
 
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Thomas Paul:
4) write an algorithm to implement garbage collection efficiently?
My answer: why?


Hmm, well, I usually ask candidates how garbage collection works. I ask them to explain the algorithms used. I'm not looking for advanced algorithm concepts, just the idea that it's not magic. Good candidtaes can provide a simple algorithm. Outstanding candidates can explain concepts like conservative, handleless, cooperative, etc.
--Mark
 
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello friends,
I was asked:
1. "what is the difference between a Thread and a process" ?
2. what is the difference between sendRedirect() and
Requestdispatcher.redirect() - A JSP question.
can anyone help ?
nice thread indeed !
Leena
 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getRequestDispatcher is a method of ServletContext
1.forward is handled completely on the server
2.preserve all the request data, request state on
the server
3.the URL of the original servlet is maintained
4.does not require a round trip to the client,
and thus more efficient
sendRedirect is a method of HttpServletResponse
1.requires the client to reconnect to the new
resource, the request is first sent to the
client which requests for the resource
mentioned in the argument of sendRedirect
method.
2.does not automatically preserve all the request
data result in a different final URL (convert
relative URL to absolute URL)
will try to answer your first question later.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi JiaPei,
when u says "does not automatically preserve", do you mean that there's a way to preserve the request when using sendRedirect?
if so, can share how to do it?
thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic