Win a copy of Terraform in Action this week in the Cloud forum!

Krish Pinnamaneni

Greenhorn
+ Follow
since Mar 16, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Krish Pinnamaneni

Hi,
We can override jspInit() and jspDestroy()in jsp page.According to my knowledge we cann't override _jspService() in jsp page.I would be great if any body tells the reason why we cann't override _jspService() in jsp page.
In advance,
Thanks,
Krish.
Hi,
As Narendra Said When the outer quotes are double quotes we need to use single quotes inside it.This is my guess.
Bye.
Krish.
Hi Narendra,
Yes,By default servlet supports multithreading. So the information in the local variables and information in the HttpServletRequest Object are Thread safe.Because For each client request,new ServletRequest Object and new ServletResponse object and new Thread will be created.After the execution of service(HttpServletRequest,HttpServletResponse) method these newly created HttpServletRequest,HttpServletResponse and Thread executed that service() method becomes candidates for garbage collection.In other way...HttpServletRequest Object is also local to service(HttpServletRequest,HttpServletResponse).So always information in the local variables are Thread safe.
Bye,
Krish.
Hi Thomas,
According to my knowledge: we will do primitive casting under following situations:
_______________________________________________________________________
Implicit conversion occurs in the following scenarion:
1] byte --> short --> int --> long --> float --> double.
Means for exazmple we can assign byte to short or byte to int like that.
Implicit conversion takes place when you follow above sequence.
_______________________________________________________________________

******************************************************************
Explict convertion(i.e. casting)is required for below scenario:
double-->float-->long-->int-->short-->byte(i.e. in opposite direction)
If you are trying to assign in the opposite direction i.e. assigning int to short or int --> byte then explicit casting is required.
*******************************************************************
Bye.
Krish.
Hi Rathi Ji,

Thanks for spending your most valuable time fo giving response.

I tried the following example:
class Base {
public void test(){
System.out.println("Super class test()");

}

}

class Sub extends Base {
public void test(){
System.out.println("test() is overriding method");
}

public static void main(String[] args){

Base ob = new Sub();
ob.test();
}

}

//output is: test() is overriding method
But my doubt is: deciding which method to be called during compile time is compile time polymorphism.
ex: Sub ob = new Sub(); //This is example for compile time polymorphism.

Deciding which method to be called at runtime is runtime polymorphism.
Super ob = new Sub();//Example for runtime polymorphism.Thanks for spending your most valuable time for giving response.
Hi,
I need detailed explanation of difference between compile time polymorphism and run time polymorphism?. How complie time polymorphism and run time polymorphism is achieved. Can any body explain with detailed example.

In advance,
Thanks,
Krish
Hi Harish,

Thanks a lot for giving response.

Thanks,
Krish.
Hi,
We know that java.util.Map is not a collection since it is not implementing Collections interface.
is there any way to convert java.util.List to java.util.Map. waiting for guidance
In Advance,
Thanks,
Krish
Hi ,
Please correct me if i am wrong.
ArrayList arList = new ArrayList();
arList.add("1");
arList.add("2");
String[] str = (String[])arList.toArray();
I know that above code will not be compiled.I need more info. why the code is not being compiled?.

My understandings:

we are adding String's "1" "2" to List.since List.add(Object) those strings are upcasted to generalized Object(i.e. java.lang.Object).so List.toArray() returns Object[].But each element of Object[] is java.lang.Object can be down casted to String since originally we added String to List.
I don't understand why it is giving compile time error?. Please validate my understandings
Thanks,
Krish.
Hi Animesh,
Please correct me if i am wrong.
ArrayList arList = new ArrayList();
arList.add("1");
arList.add("2");
String[] str = (String[])arList.toArray();
I know that above code will not be compiled.I need more info. why the code is not being compiled?.

My understandings:

we are adding String's "1" "2" to List.since List.add(Object) those strings are upcasted to generalized Object(i.e. java.lang.Object).so List.toArray() returns Object[].But each element of Object[] can be down casted to String since originally we added String to List.
I don't understand why it is giving compile time error?.Please validate my understandings
Thanks,
Krish.
Hi Animesh Shrivastava ,

Thanks a lot for spending your most valuable time to give response.

Thanks,
Krish
Hi ,
I am telling my understandings regarding extending or instantiating or referencing class A in package source from class C of package destination.
Please tell any body have better idea regarding this.
Thanks,
Krish .

package source; package source;

public class A { class C { }
static int I =10;
A () {}
}

Q1] what are the conditions to instantiate, extend, refer class A by class C of same package source

A] Extending class A by class C of same package:
constructor of super class must not be private. It could be either default or public or protected.

B] Instantiating class A in class C of same package (i.e. source)
Just you can do it using new operator unless class A constructor is private.

C] Referening Class A in class C of same package (i.e. source)
We can do that if Class A is having public or default static members only.
____________________________________________________________________


package source; package destination;

public class A { class C { }
static int I =10;
A () {}
}


Q2] what are the conditions to instantiate, extend, refer class A in source package from class c of destination package


A] Extending class A in by class C of different package say destination;
Then class A must be public and its constructor must be either protected or public.

B] Instantiating class A in class C of different package say destination (i.e. package destination)
Then class A must be public and its constructor must be public.

C] Referencing class A in class C which is in different package (i.e.destin ation)
Then class must be public and only its public static members are accessible.
Hi,
Can any body tell me with example regarding following method
List.toArray(Object[]).
I know that List.toArray() returns generalized Object[].
In Advance,
Thanks,
Krish
Hi,
Can any body help me how to convert java.util.List a1 = new ArrayList();
to Object[] .
In Advance,
Thanks,
Krish
Hi Jeroen Wenting ,
Thanks a lot for your response.
Thanks,
Krish