Você está na página 1de 4

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);  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?  System.gc();

5) What are Transient and Volatile Modifiers?

6) Reflections?

try {
Class c = Class.forName("java.awt.Dimensions");
Method methods[] = c.getMethods();
Filed fields[] = c.getFields();
Constructor constructors[] = c.getConstructors();
} catch (Exception e) {
System.out.println(e);
}

1
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.

Example:

String s7;
String S6 = new String();
System.out.print("S7 "+s7); //Variable s7 "might not have been
intialized"
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?

2
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


variable

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.

***********************************************************************************

1) 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.

3
Functions does not return images where as Proceudres yes.
Functions take only “IN” as parameter and where as Procedures takes “IN”and
“OUT” parameter.

2) Trigger:

Database Triggers are stored procedures that is fixed when insert, update,
delete statemets are issued against the associated table.

Used: To create the date automatically.


To manupulate the data’s.

Types of tiggers: Before, After, for each row, for each statement.

***********************************************************************************

Você também pode gostar