Lokesh Mahajan

Greenhorn
+ Follow
since Feb 01, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Lokesh Mahajan

Hello Dear
class Base {}
class Sub extends Base {}
class Sub2 extends Base {}
public class CEx{
public static void main(String argv[]){
Base b=new Base();
Sub s = new Sub();
b = s;
s=(Sub) b;
}
}
Try to run this program, it will run now.
Lokesh
[This message has been edited by Lokesh Mahajan (edited March 22, 2001).]
23 years ago
Hello Dear
I tried it once again its working perfectly on my m/c,home jndi name is given from client class. here is the method of the client class.

InitialContext ic = new InitialContext();
System.err.println("looked up initial context");
BagHome bh = (BagHome) ic.lookup("BagHome");
this BagHome is the name given to the home interface,
after clicking save its creating xml files, but before generating a container every time I have to select
go to Tools>preferences>choose and than select the again javac.exe of the jdk1.2.1.I dont know why but i have to do it every time before generating the container,
Also I forgot to mention one thing after contaner is generated successfuly again you have to click on the save button at this junction all the stub & skeleton files will be seen in your edit pannel.
hope this will help you out in some way,actually i am also new to this & after lots of effort i was successful in deploying the heelloworld stateless bean.
Love
Lokesh
23 years ago
Hello Dear
the answe is right it's 15,
i*=2 + i++;
1> i= 3 ;
2> i++ this is postincrement so value of i remains 3
3> 2 + i++ = 5,
4>i*=5 (now its become 5) so its evaluted as i = i * 5 i.e.(i= 3 * 5) = 15,
so answer is 15,
if it was like this i*=2 + ++i;
than
1> i = 3;
2>++i= 4 (because its preincrement but i remains 3 only);
3> 2+4 = 6;
4>i*= 6 (so its become i = 3 * 6 )
5> 18
so in this case it will print 18,
correct me if i am wrong.
Love
Lokesh
Hello Dear
In first example insted of RunTest it should be RunThread,
Problem is what is going to print "running",so if you give just simple System.out.println("running"); it is going to print "running", here it is not going to call run method,so only single "running"is the output.
so both the option given are correct.
About 2 question.
option d is also right because it is the case of overloading ,
option b & c are the case of overriding.
love
Lokesh
23 years ago
Hello Dear

Originally posted by thiru chakravarthi:
Hi,
It might look silly...But I want to know, even if it gets resolved in run time, the value of both the string are same.So why it is still printing 'false' instead true.
Is it comparing whether two string variables are pointing to same value or it is comparing the real value of both the strings variable?


the things is like this you are not comparing by means of "==" the value but the location where it gets stored,so st1 is pointing towards some different location & st5 or st4+st3 are pointing towards some other location.so the result is false.
But when you used the equal method you are comparing actual value so the result is true.
Love
Lokesh
Hello Dear
I follow the following steps to deploy the simple helloworld example of stateless bean.
compile all the files (remote interface ,home inteface , bean class , client class)
then open ejb deployer tool
click on file > new browse the path to weblogic/myserver
give the file name say xyz.jar
click on the finish.
now click on the xyz you will see that all the button get enabled,
click on the "edit file set" button(click on "project" & "select edit file set")Add & remove project file window will open up.
click on the add button to add files(your remote interface , home interface & bean class which implements sessionBean & any other relevent class but not the client class).
click on ok button.
click on the bean than select bean after this you will see two tab pages in the edit pannel(its bean name & classes)click on the classes tab give the "Home JNDI Name"its the same one which you have given in the client class (lookup() method of the InitialContext)it is actually the name of home interface)
click on the save.
after this you will find that two xml file are generated.
click on the tools>prefences>
select ejbc,click on the choose button of the ejbc properties,
browse down to javac.exe file of your jdk1.2.1
check the true radio button click on ok button.
after this click on the "generate container" button,if every thing is right container will generated,
after this start the weblogic server.
after this click on the tools>deploy to> myserver
thats all you have to do it,& thats what i did to deploy stateless bean.
hope you understand the things.
Love
Lokesh

23 years ago
Dear Friends
I am new to weblogic just started going through it.
I am using weblogic 5.1.0 server,
How I went through in deployment procedure?
note : all the classes are public & are stored in the storekeeper directory. all the classes are compiled with no error.
I opened up deployer tool, created a new jar file in the myserver folder of weblogic.than added the bag.class,baghome.class,bagbean.class,inventoryitem.class,itemnotfoundexception.class in it.
than home jndi name is given as "BagHome" as specified in the client class in the lookup.also maintains conversational state check box is checked(because its statefull bean)
than this is saved. after this files in the edit panel shows two more files
weblogic-ejb-jar.xml & ejb-jar.xml & the path shown is meta-inf.
after this I clicked on the generate container.
container is generated successfuly,all the stub & skeleton files are generated and are there in the edit pannel of the deployer tool.
after this i click on the deploy button, but while deploying it is giving following error.

- with nested exception: [weblogic.ejb.common.DeploymentException: Problem creating deployment e:\weblogic\myserver\store2.jar from e:\weblogic\myserver\store2.jar; nested exception is:
java.lang.NoClassDefFoundError: storekeeper/InventoryItem]
Deployment failed.
-----------------------------------------------------------------
the thing is that InventoryItem is there in storekeeper & edit panel is also displaying it ,along with there are all stub & skeleton files are also there.this is an example of statefull beans.

Am I missing some thing,
Thanks in advance.
love
Lokesh
23 years ago
Dear Nayyer
in ref. to your statement.
anObj.trim(); as "sample" have nothing to trim so no new obj get created nor u r dislocating the anObj so an obj is still pointing the smae "sample"
---------------------------------------------------------------
you are right that if there are no spaces as in the case of "sample" anObj.trim() will not create new obj. but this is only true if your newly created obj. is refered by some varible.
ie anObj = anObj.trim().
public class Hi
{
public static void main(String args[])
{
String s1 = " sample ";
s1.trim();
System.out.println(s1);
}
}
here in this example it is not going to trim the spaces of the s1
because you are not storing the newly created obj. after triming,
but in the following example
public class Hi
{
public static void main(String args[])
{
String s1 = " sample ";
s1 = s1.trim();
System.out.println(s1);
}
}
here in this obj. created after triming is store back in the s1, so here if you print the s1,you will find that the spaces are trimed,
So though " sample" is used insted of just "sample" it would have no effect, because new obj created is not refered by any variable just s1.trim() does not store the obj. back in s1.
Love
Lokesh



Hello Dear
The things are like this in your first example, object is garbage collected when the reference pointing to the object cannot get them.
first off all the strings are immutable.
in this case anObj.trim() you are not storing the result.so nouthing will happens.
but when you say anObj=anObj.toUpperCase() here after this anObj is pointing towards some different & not on "sample",so you cannot get back your object "sample", after this line its lost.so it is garbage collected.
In second question locObj is a local variable its scope is limited to its block only.
here "sample" obj. is refered by two varible namingly anObj & locObj, so though anObj is become null "sample" is still refered by the locObj & is not lost."sample" lost only after the scope of the block ends means after line no 11.
Love
Lokesh
Hello Dear
In the main method you have created the object of the Sub & on this object you called the method g(),
Now since g() is not there in Sub class it will search for higher class from which this Sub class is extended in this case it is Tester.
In g() methods it again calls the f(),now the f() method is there in both the classes but this class(Tester-top class) only knows the method in there class & not from the derived class.
so it is calling the method from the top class there by printing 2.
love
Lokesh
Hello Dear

The things works like this according to me.
after setting lay out to flowlayout you have added the componenet ,than you have not set its setvisible property to true.
Than you have set again the layout manager to borderlayout,here you set it visible property to true, but your border layout does not contain any componenet to display it,so it is showing blank screen.
love
Lokesh
23 years ago
Hello Dear
Microsoft platform independent language is c#(called as C Sharp)
its beta ver. is avaible & is very close to our own java with just different naming convention.lets watch & see how it takes up, but one thing for sure when Microsoft is behind it is definatly going to create a impact.
Lokesh
23 years ago
Hello Dear

I think the answer is c ie. 4 .
the thing is like this String str is declared out side the function body. so when str is created by means of for loop ,earlier one created is getting garbage collected,this keep on happning till i= 4, after this for loop getsa terminated, and the only reference left is when the value of i is 4.
which is not garbage collected.
lokesh mahajan
Hello Dear
I dont find any thing in it I think you are missing some thing ,your point i am not getting it.
lokesh mahajan
23 years ago
Hello Dear

In your program you are calling y.test(1) here it check in the FinalOverLoadSub class for the method but it doesent find there its match(though double is accepting an int type void test(double a)).
Now this class is extended from FinalOverLoad so it goes there to find the desired method void test(int a) & it find there.
now the compiler had two method to execute so it is creating an ambiguity.
Now just go through the modified program of yours.
class FinalOverLoad{
final void test(double a){//changes made here.
System.out.println("Final Integer Matrix A = " + a);
}
void test(int a){//changes made here
System.out.println("Final Double Matrix A = " + a);
}
}
class FinalOverLoadSub extends FinalOverLoad{
void test(int a){//changes are made here.
System.out.println("Value of A(INTEGER) in Sub " + a);
}
}

public class TestFinalOverLoad{
public static void main(String args[]){
FinalOverLoad x = new FinalOverLoad();
FinalOverLoadSub y = new FinalOverLoadSub();
x.test(1);
x.test(1.0);
y.test(1);
}
}
it will work fine,
Now again if you put all these method in one class & than try to run the program it will not create a prob for you.
for ex.
public class T {

final void show(int i) {
System.out.println("In integer " + i);
}

public void show(double i) {
System.out.println("In double " + i);
}

public static void main(String args[]) {
T t = new T();
t.show(1);
t.show(1.0);
}
}
this will run fine .
class X{
final void show(int i) {
System.out.println("In integer " + i);
}
}

public class T extends X{



public void show(double i) {
System.out.println("In double " + i);
}

public static void main(String args[]) {
T t = new T();
t.show(1);
t.show(1.0);
}
}
here it will say for an aambiguou method.
by now you must have understand the thing.
lokesh