swati aole

Greenhorn
+ Follow
since May 02, 2009
Merit badge: grant badges
For More
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 swati aole

hi all,

It's just a simple query about the implementation mechanism of java. I want to know how Threads work in java. I mean it's just a class like other classes and implements Runnable but we can define any such class with run and start methods but it won't work like Thread class. Are there any language specifications used to identify it as a special class. If yes, please tell me how they are implemented, via compiler, interpreter or JVM?? which one recognizes and differs special classes.

thanks in advance.

Regards
Swati
14 years ago
Thanks a lot Patricia for finding time to resolve my query.

Warm Regards
Swati
14 years ago
I created one class 't' with overloaded method show(), when I call it with show(null) it gives compile time error saying 'ambiguous' reference, when there are two overloaded methods show(t a) and show (tt b). (both subclass to t1).

but when I overload the methods show(t a) and show (t1 b) and call it with show(null) it runs fine with the subclass argument version of show.. I thought it might give error here also because t1, t, tt all are subclass to object..

please tell me the reason why it compiled with overloaded method with super and subclass argument but not with sub and sub argument. Thanks in advance.

Here is the code:
---------------------------------------------------------
import java.io.*;
abstract class t1
{
abstract void show();
}

class tt extends t1
{
void show(){}
}


public class t extends t1
{
void show(){}


void show(t1 t) //super
{
System.out.println("t1");
}

void show(tt t) // sub2
{
System.out.println("tt");
}

public static void main(String ar[])
{
new t().show(null);
}
}
// this is compiled--------------------------------------------



---------------------------------------------------------
import java.io.*;
abstract class t1
{
abstract void show();
}

class tt extends t1
{
void show(){}
}


public class t extends t1
{
void show(){}


void show(t t) // sub1
{
System.out.println("t");
}

void show(tt t) // sub2
{
System.out.println("tt");
}

public static void main(String ar[])
{
new t().show(null);
}
}
// this didn't compile--------------------------------------------

Regards
Swati
14 years ago
Hi all,

I am working on a project using jsp and AJAX. I need to display images on my jsp page according to image file name selected by user. The problem is that, I can't use relative path to retrieve images because there are thousands of images and I can't store them in some img folder and attach the same at the time of deployment in my project.

So I was using the absolute image path with "<img src>" and it was working fine, but it's not working with the enhanced browser version. When user installs the latest flash player version, images are not displayed neither the "alt text", only the empty image frame is displayed.

I am stuck here and can't find the reason. Please give suggestions for implementation of this functionality.

Thanks in advance.

Regards
Swati
14 years ago
JSP
hi all..

I am trying this code:

class v extends Thread{
public void run() {
System.out.print("go ");
}
public static void main(String [] args){
try
{
Thread t1 = new v();
Thread t2 = (t1);
t1.start();
t2.start();
}
catch(Exception e)
{System.out.println(e);}
}
}


output

D:\>java v
java.lang.IllegalThreadStateException
go


I am confused from this output ... If we invoked start() again on the same Thread obj... it will throw IllegalThreadStateException.. but how come after the exception is thrown it is printing the "go"... the program should get terminated.
So if the firstly started thread gets the chance to run it should print "go " and then the exception or only the exception... how come it is printing a message from run() after an exception is thrown..???
please send some explanation..Thanks

Campbell Ritchie wrote:You are calling the inner class constructor from the outer class constructor. When you get to that constructor, there is implicitly an instance of the outer class in existence: the one being created at the moment.



Thanks a lot Campbell.. I always thought that the object doesn't get created and initialized the memory space until the constructor code executed completely.. could you please provide some explanation about the object creation and memory allocation process in java?

Regards
swati
14 years ago

Sona Patel wrote:I can not copy paste exact code but below is the snap shot of it
Classes are as below




I think the java.lang.NoSuchMethodError is thrown because the interpreter is trying to find main() which you'ven't provided..
14 years ago

swati aole wrote:Hi all experts..

I am new to java ranch... I tried invoking the inner class constructor() inside the main class constructor and it worked properly.

How come?? I thought we need outer obj to create inner obj so the compilation might fail..

please send some explanation.

Thanks in advance.



here is the code:

class testC
{
testC(){
new inner();
}
public class inner{
void show(){}
}
}

I am invoking the inner class constructor inside the outer constructor and it compiled ... but we need an outer obj to create inner obj ... so how can we create the inner obj before outer constructor generated an outer obj..
Thanks.


no I am not from mumbai and it would be great if anybody could send some explanation on this topic..
14 years ago
Hi all experts..

I am new to java ranch... I tried invoking the inner class constructor() inside the main class constructor and it worked properly.

How come?? I thought we need outer obj to create inner obj so the compilation might fail..

please send some explanation.

Thanks in advance.
14 years ago