• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Interview Questions

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have got some real(not cooked up) interview questions . Here it is:

1.Your web application needs to access a table in database at regular intervals. Keeping in mind separation of concerns, minimizing load on the database and re-usability of your code, describe your solution to this?

2.Your application is mission critical and you need to make sure that it is running 24 hours a day. Describe a solution that ensures that the application notifies you if it crashes, its not running or if there are any serious errors?

3.Your application has some problems and is crashing a few times a day. What steps would you take to try and find the cause of the problem?

4.With a code example, show how you would iterate over a collection of objects in a jsp page AND in a java class.

5.Thinking about MVC on the client side, how would you apply an MVC architecture to CCS, JavaScript and your Web Page? Give a code example of attaching a JavaScript function to an onclick event of a button whilst obeying MVC.

I very much appreciate your comments. Please share your answers.

Thanks,
Joe.
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

4. With a code example, show how you would iterate over a collection of objects in a jsp page AND in a java class.



IF your collection is say
ArrayList myCollection
and you want to iterate it you use the Iterator.

Iterator itr = myCollection.iterator();
while(itr.hasNext()){
Object obj = itr.next(); //return single element/object from collection.
}


//here i have use Object reference instead your specific object type will come which is held in the collection. Ex. for me it may be MyCollectionObject.

Hope this helps.

Thanks!
Rohit Nath.
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rohit Nath:


IF your collection is say
ArrayList myCollection
and you want to iterate it you use the Iterator.

Iterator itr = myCollection.iterator();
while(itr.hasNext()){
Object obj = itr.next(); //return single element/object from collection.
}


//here i have use Object reference instead your specific object type will come which is held in the collection. Ex. for me it may be MyCollectionObject.


Most of the time it is better to use a "for" loop to iterate than a "while" loop because scope of the iterator object would be limited to the "for" loop .
 
Rohit Nath
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In JSP you can iterate using logic tags.

logic: present and logic: iterate tags

1) <logic: present name="MyFormBean" property="myVOs">

2) <logic: iterate id="myVO" name="MyFormBean" property="myVOs" type="MyVO" indexId="i">

3) access individual element using scriptlet or anyway you want...
< % myVO.myProperty()> //here you can access your individual element.

4) close both tags with ending tags
</ logic: iterate>
</ logic: present>

MyFormBean will be logical name of form bean associated with your JSP. (specified in your struts-config.xml form-beans declarations)
[ November 06, 2006: Message edited by: Rohit Nath ]
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Using JSTL <c:forEach> tag is the simplest way to iterate over a collection of object. Here is the example.

Say 'arrayListItem' is available within request Scope.

<c:forEach var="listItem" items="${arrayListItem}">
<c ut value="${listItem}"/>
</c:forEach>

This will print the value of items, indexwise.

Manish
 
Manish Shah
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<c:forEach var="listItem" items="${arrayListItem}" varStatus="indexNo">
<c ut value="${listItem}"/>
</c:forEach>
 
Rohit Nath
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

3. Your application has some problems and is crashing a few times a day. What steps would you take to try and find the cause of the problem?



Not sure about this one but there can be some preventive measure to track problem like.

The solutions can be but are not limited to the following.

1. Maintaining a log file. it may be a simple text file in which logs are maintained. A simple utility method can be written that can help add log comments throughtout the application code.
2. maybe Exception handling can prevent it.
3. checking memory resource usage. example there are some constraints on memory usage for example a JSP file if is including other files beyond a particular limit then an error occurs.
4. Other aspects like scalability issues... number of users exceeding the allowed limit.

Please correct me if I am wrong.

Thanks in advance!
Rohit N
[ November 06, 2006: Message edited by: Rohit Nath ]
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


1. Your web application needs to access a table in database at regular intervals. Keeping in mind separation of concerns, minimizing load on the database and re-usability of your code, describe your solution to this?



Use the DAO pattern. If the table values in the database will not change frequently, use a copy of the object that represents the DB to perform calculations.


2. Your application is mission critical and you need to make sure that it is running 24 hours a day. Describe a solution that ensures that the application notifies you if it crashes, its not running or if there are any serious errors?



What kind of application ? A normal java app, swing ?, web application ? Either way if the error is serious you could use an email service to send notifications. If you want on the spot notification use a mobile phone with GPRS service or use a GSM transponder to send and recieve SMS. There is also bluetooth. Before I do all of this I would first try to find out the source of those serious errors and disable non critical functionalities if possible.


3. Your application has some problems and is crashing a few times a day. What steps would you take to try and find the cause of the problem?



Look at the log files. If that does not help perform a live debug on a simulated environment. Add extra debug statements if necessary. If it is crashing in the live environment I would once again look at pulling the module that causes the problem out of action first, if thats possible.



4. With a code example, show how you would iterate over a collection of objects in a jsp page AND in a java class.



For java classes use the for each loop, or an iterator. Use the c : forEach element for JSP pages, or script it if you are desperate. It can also be done with custom or simple tags but thats overkill considering that these simple functionalities are already available. Oh ! and if you are using struts use the logic : iterate element.

[EDIT] arrghh ! the page wont accept angled brackets in my reply


5. Thinking about MVC on the client side, how would you apply an MVC architecture to CCS, JavaScript and your Web Page? Give a code example of attaching a JavaScript function to an onclick event of a button whilst obeying MVC.



CSS right ? ahhh... this I do not have an answer to. Perhaps I will when I finish reading a couple of AJAX books
[ November 06, 2006: Message edited by: John Meyers ]
 
Joe Jose
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all for the replies.

Those are all essay type questions. SO I think we should elaborate a little more.
 
this is supposed to be a surprise, but it smells like a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic