sreekanth


{ City } pune
< Country > india
* Profession * s/w engineer
User No # 37518
Total Questions Posted # 1
Total Answers Posted # 8

Total Answers Posted for My Questions # 2
Total Views for My Questions # 18083

Users Marked my Answers as Correct # 117
Users Marked my Answers as Wrong # 13
Questions / { sreekanth }
Questions Answers Category Views Company eMail

difference between request.getSession(false) or request.getSession() and request.getSession(true)

2 Servlets 18083




Answers / { sreekanth }

Question { TCS, 277935 }

Difference between abstract class and interface


Answer

1. Abstract classes can have implementations for some of
its members (Methods), but the interface can't have
implementation for any of its members.

2. Only an interface can extend another interface, but any
Class can extend an abstract class..
3. Class can inherit only one abstract class, but class can
implement more than one interface
4. An abstract class can contain constructors, but
interface can’t contain any constructors

5. An abstract class can’t support multiple inheritances,
but an interface can support multiple inheritances.
EX:- class A extends AbstractClass
Class A implements interface1, interface2

6. We can use various access modifiers to variables. such
as abstract, protected, internal, public in Abstract Class,
but all of the variables in an interface are implicitly
(Default) static and final.

7. An abstract class can contain abstract and non-abstract
methods, but interface contains only abstract methods. If
we declare the method without having abstract, by default
it takes that method as abstract method

Is This Answer Correct ?    2 Yes 0 No

Question { L&T, 16468 }

which situation you use static include and dynamic include
in jsp?


Answer

This is Static include.
<%@ include file="header.jsp" %>
1.the file includes static text. i.e if we use the static
include, it will merge the contents of included jsp
(header.jsp) with main jsp at compile time. and the size of
the main jsp will increase. some times it may have problem,
because the maximum size of the jsp is 64kb.
2.if the file is changed,the JSP engine may not recompile
the JSP

This is Dynamic include.

1.The file includes Dynamically. i.e at run time.
2.If the included file (header.jsp) is changed,the JSP
engine recompile the included JSP, because it will include
at run time.By using this the jsp size also not increased.
For Example
Static include (<%@ include file="header.jsp" %>) like our
#include (C++)
Dynamic include ( ) like our
import (JAVA)

Is This Answer Correct ?    46 Yes 3 No


Question { TCS, 12347 }

Hai all.Can i develope Struts action class without execute(-,-
,-,-)method.Ifd it's possible plz provide some sample code.


Answer

If your Action class extends from Dyna Action Action, then
you can develop struts action class with out execute
method. Because in that action class we write our own
methods insted of execute method.

EXAMPLE:
public class Dispatch_Action extends DispatchAction
{

public ActionForward add(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
System.out.println("You are in add function.");
return mapping.findForward("add");
}

public ActionForward delete(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
System.out.println("You are in delete function.");
return mapping.findForward("delete");
}
public ActionForward search(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
System.out.println("You are in search function");
return mapping.findForward("search");
}
public ActionForward save(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
System.out.println("You are in save function");
return mapping.findForward("save");

}
}

Is This Answer Correct ?    20 Yes 3 No

Question { TCS, 7179 }

can someone tell me how does preparedstatement works? its
an interface and where is the implementation?


Answer

1. Yes PreparedStatement is and interface. It was in
java.sql package.
2. PreparedStatement interface creates an object that
represents a precompiled SQL statement. By using this we
can protect from SQL Injection.

Is This Answer Correct ?    1 Yes 3 No

Question { iFlex, 8687 }

What is servlet preinitialization?


Answer

Servlet can loaded in servlet container of web or
application server at the time of first request sent to
that servlet.
If we want to preinitialized the servlet by using startup> tag(Aritten in web.xml). If we use that tag,
servlet is intialized at the time of server start.

Is This Answer Correct ?    7 Yes 0 No

Question { Rolta, 13740 }

Map map = new HashMap(2);
map.add(“1”,”one”);
map.add(“2”,”two”);
map.add(“3”,”three”); What will happen at this line?


Answer

We don't have a method add() in HashMap.
We have put().
Map map = new HashMap(2);
map.put("1","one");
map.put("2","two");
map.put("3","three");
System.out.println("Size of the map="+map.size());

If we wrote like this, it will extend the size.
The out put is: Size of the map=3

Is This Answer Correct ?    18 Yes 2 No

Question { Rolta, 6903 }

What will be the output of the program?

public class Test {
public static void main(String args[]) {
ArrayList list = new ArrayList();
list.add("2");
list.add("3");

list.add("4");
list.add("5");
System.out.println("size :"+list.size());
for(int i=0;i list.remove(i);
}
System.out.println("size after:"+list.size());
}
}


Answer

Step 1: The array size: 4
array is list[0]=2, list[1]=3, list[2]=4, list[3]=5;

i=0;i<4;i++
it removes the 0th element, means it removes 2.
now the array is list[0]=3, list[1]=4, list[2]=5

Step 2: Now the size of the array is 3
now i=1 (bcz i++)
i<3;i++
it removes the 1st element, means it removes 4 (Bcz i=1).
now the array is list[0]=3, list[1]=5

Step 3: Now the size of the array is 2
now i=2
the condition is fail in for loop (bcz i=2. means 2<2)
So it won't go inside the loop

So the size after:2

The final Output is
size :4
Size after:2

Is This Answer Correct ?    13 Yes 0 No

Question { Photon, 7023 }

"Sun Certified Java Programmer" This is one String , we need
to print SCJP, write the java code dynamically? pls reply
this questions


Answer

public class Sample {
public static void main(String args[]) {
String str = "Sun Certified Java Programmer";
String str2 = null;
for(int i=0;i {
char c = str.charAt(i);
if(Character.isUpperCase(c))
{
if(str2 == null || str2 == "")
str2 = ""+str.charAt(i);
else
str2 = str2+str.charAt(i);
}
}
System.out.println("Result="+str2);
}
}

Is This Answer Correct ?    10 Yes 2 No