Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Interview Questions

Interview Questions

Ratings: (0)|Views: 63 |Likes:
Published by api-26407176

More info:

Published by: api-26407176 on Nov 29, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





1) How do i print the stackrace for an exception occuring within the JSP Page?
<%@ page isErrorPage="true" %>
<% PrintWriter pw = res.getWritter();

exception.PrintStackRace(pw); %>
2) Can We override jspInit() or How do we pass initparameter to JSP?
<% ! public void jspInit() {
} %>
3) Diff between Session and Cookie?

Session will accept Object and values. Where as Cookie accept only values.
4) Diff between WebServer and ApplicationServer?
Only Http Protocol is allowed in Webserver where as any type of protocol is
allowed in Application Server.
Used only for JSP or Servlet technolgies in Webserver. For EJB deployment

Application server should be used.
Application Servers can be configured to behave as Webserver.
Whenever the request comes from the user, the request is just passed to the

Webserver and no other business logic is performed in webserver.
5) What is preInitializing or preLoading? -> <loadon-startup> tag.
6) Diff Between req.getSession() and req.getSession(true);\ue000 No diff
7) Diff Between req.getSession(true) and req.getSession(false);

When you say getSession(false), this method will check whether a session is existing. If yes, then it returns the reference of that session object, OTHERWISE IT WILL RETURN 'null'.

1) How do we allocate a memory to a object? -> new operator.
2) What is the use of bin and lib in JDK?
3) Diff between Parameter and Argument?
4) What is Garbage Collection and how to call it explicitly?\ue000 System.gc();
5) What are Transient and Volatile Modifiers?

try {
Class c = Class.forName("java.awt.Dimensions");
Method methods[] = c.getMethods();
Filed fields[] = c.getFields();
Constructor constructors[] = c.getConstructors();

} catch (Exception e) {
7) Shallow Copy: Clone method() is called Shallow Copy.
This means value of all the orginal Object fields are copied to the fields
of new object
The syntax for calling clone in Java is:
Object copy = obj.clone();
or commonly
MyClass copy = (MyClass) obj.clone();
8) Deep Copy: Serialization.
9) Young Copy: Garbage Collection.
10) Can there be an abstract class with no abstract methods in it?
11) Can an Interface be final?
13) Can a lock be acquired on a class?
Yes, a lock can be acquired on a class. This lock is acquired on the class's

Class object.
14) What is the difference between the >> and >>> operators?
15) What state does a thread enter when it terminates its processing?
16) What happens to a static var that is defined within a method of a class ?
17) To what value is a variable of the String type automatically initialized?

The default value of an String type is null.

String s7;
String S6 = new String();


System.out.println("S6 "+S6); //default empty
18) Can a for statement loop indefinitely?
19) What if the main method is declared as private?

The program compiles properly but at runtime it will give "Main method not
public." message.
20) What if the static modifier is removed from the signature of the main method?
Program compiles. But at runtime throws an error "NoSuchMethodError".
21) What if I write static public void instead of public static void?
Program compiles and runs properly.
22) How can one prove that the array is not null but empty using one line of code?
Print args.length. It will print 0. That means it is empty.
23) Can an application have multiple classes having main method?

Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having main method.

24) Types of Exception?
Checked Exception: User is aware of the excetion and he is able to catch it.
UnChecked Exception: Unchecked exceptions are RuntimeException
25) Are the imports checked for validity at compile time? e.g. will the code
containing an import such as java.lang.ABCD compile
26) Does importing a package imports the subpackages as well? e.g. Does importing
com.MyTest.* also import com.MyTest.UnitTests.*
27) What is the default value of an object reference declared as an instance
28) Can a top level class be private or protected

No. A top level class can not be private or protected. It can have either "public" or no modifier. if a top level class is declared as private the compiler will complain that the "modifier private is not allowed here"

29) If I write System.exit (0); at the end of the try block, will the finally block
still execute?

No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never executes.

30) What is daemon thread and which method is used to create the daemon thread?

Daemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the java runtime system. setDaemon method is used to create a daemon thread.

Diff Functions and Procedurces?
Functions return only 1 value and Procedures return multiple values.
Functions must return a value and wheres as Procedures may not.

Activity (6)

You've already reviewed this. Edit your review.
1 hundred reads
cafael liked this
shaminbabu liked this
hello1982 liked this
raky25 liked this
John Tutton liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->