Clintech Whole Testpaper |   2846

Clintech Whole Testpaper

 

CLINTECH RESEARCH PAPER ON 23rd  SEPTEMBER
 

Hai guys,
I m finally selected in Clintech Research.


Q1. Will the following code compile?
If yes, what is the output on line 7?
If no, how will you fix the code? Once fixed, what will be the output on line 7?
1. String str= "Hello/World/This/is/a/test";
2. String[] val = str.split ("/");
3. for ( int j = 0; j < val.length; j++){
4.  List a = new ArrayList();
5. a.add(val[j]);
6. }
7. System.out.println("List size:" +a.size());

Q2. If you have to store data as key-value pairs, which data structure will you use? Please show code to add and delete elements from this data structure using the Java APL.
Example: You declare the data structure called "myinfo" and you store data (key, value pairs) in this data structure as:
"firstname", "Hari"
"lastname", "Gupta"
"phone", "123456789".
Then myinfo.get("firstname") should return "Hari" etc.

Q3. Write code to show how you can pass an object from a servlet to JSP and how you can retrieve that object in the JSP?

Q4. Let's say you have a JSP which has a form that the user can fill out. The form submits to a servlet. In the servlet, one of the form inputs needs to be used as integer. Write code to show how you will retrieve this particular form value in the servlet and convert to integer value? Please mention any exceptions that may be thrown and how you would handle it in code.

Q5. In a 3-tier web application, what are the 3 tiers? If you have to add code to retrieve values from the database, which tier will the code be a part of?

Q6. Write a java program with a main() method (not JSP) to do the following:
Ask user to enter his full name.
When the user enters his name, parse the input into 2 fields -- First Name, Last Name.
Then display it back to the user as "<lastname>, <firstname>".
Example, if I run the program, I get:
> Please enter your full name: Sachin Tendulkar
> Tendulkar, Sachin

In your code, be sure to handle exceptions - what happens if the user does not enter anything, just hits "return"? Or what happens if the user enters more than two names, like "Vijay Kumar Chaurasia"?

Q7. When do you get a "ClassNotFoundException"? How will you fix it?

Q8. When do you get an "ArrayIndexOutOfBoundsException" and how will you fix it?

Q9. What exception will the following piece of code throw? How can you fix it?
boolean check = false;
String x = null;
if(check) x = "Testing";
System.out.println("string length ="+x.length());

Q10. What is a WAR file? What java tool would you use to create one?
 By,
Mritunjay Kumar.

feedback