Maitham H

Greenhorn
+ Follow
since Jan 07, 2001
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 Maitham H

man,
this is really a tough one
ranchers.... anyhelp !!
hi all
am taking the test early next month, i think i can join too in your discussion
but how can we do this
do we keep on posting on Javaranch or what
what is wrong with using the normal way of creating an instace of the outer class
i.e Outer outer = new Outer();
i have the following code and it does compile and run perfectly
for the last part of your questions, try to carefully read and understand the objectives of the exam as stated in the sun web site, they give you good idea on what to read and concentrate on.
The golden rule is that a method overriding another method that throws an exception, must throw either the same exception or an exception that is subclassed from the original method exception or it can throw NO exceptions at all. anything else, and you have a problem in your code.
No , they are not the same
getAttributeNames return a list of available attributes in the servlet context
getParameterNames return a list of all the parameters (the one in past in the URL) to the servlet
for more details, refer to the J2EE documentaion.
and search for the two methods above.
try this

[ January 08, 2002: Message edited by: Cindy Glass ]
16 years ago
sumathi,
lets take the second class
-------------------------
public class MyClass {
public static void main(String args[]) {
String s1 = new String("Test One");
String s2 = new String("Test One");
if ( s1== s2 ) {
System.out.println("Both are equal"); //line 1
}
Boolean b = new Boolean(true);
Boolean b1 = new Boolean(false);
if ( b.equals(b1) ) {
System.out.println("These wrappers are equal");// line 2
}
}
}
-------------------------
if you compile and run this class you will get no output
why??
lets see why.
in line 1 , this will not get execuated, because s1 and s2
are two different objects.
and we know that == test the equality of the objects, not
the equality of the value of the object.
in line 2, this will not get execauted, because b and b1 have
different values inside them , b is false, and b1 is true,
and we know that the equals() test the values of the objects.
if we want both line 1 and line 2 to get executed, we must do
the following changes to the code
-------------------------------
public class MyClass {
public static void main(String args[]) {
String s1 = new String("Test One");
String s2 = new String("Test One");
if ( s1.equals(s2) ) { // here we are using the equals() not ==
System.out.println("Both are equal"); //line 1
}
Boolean b = new Boolean(false); // here we changed b to be false
Boolean b1 = new Boolean(false);
if ( b.equals(b1) ) {
System.out.println("These wrappers are equal");// line 2
}
}
}
-------------------------------
now line 1 will get executed, becase we are using the equals(),
and this tells us to test the values of the two objects s1 and s2
and since both have the value "Test One" then the if statement
will return true, and line 1 will get executed.
line 2 will also get executed, becase now both b and b1 have
the same value (false) , and we know the the equlas(), comapre
the values of the objects, then line 2 will get execuated.
I hope this helps
Maitham
sumathi,
in your first class, you can't do the following:
-------------------------
boolean b = true;
boolean b1 = false;
if ( b.equals(b1) ) {
System.out.println("true");
}
-------------------------
both b and b1 are primitive types and not Objects , and the equals method operate only on Objects.
I think the first class will not even compile.
ok , so that is out of the way, let us now talk about the difference between == and equals
the == operator evaluate both sides, and check if they are the same or in another way if the have "the same content"
for example, if you have 2 variables
int i1 = 9;
int i2 = 9;
if we use the == operator on them like this (i1==i2) we are trying to compare their values.
however you can't do (i1.equals(i2)) because as I have said, the equals only operate on Object and i1 and i2 are not objects.
now the equals operator test NOT the values of the operands, BUT THE OBJECT REFERENCE ITSELF , (i.e. it test if both operands are of the same object)
lets take an example
say we have 2 objects
String s1 = "one";
String s2 = "one";
now if you know something about the JVM, you will know that since both s1 and s2 has the value "one", then both of them refer to the same location in memory (which will contain the value "one"), therefore they both refer to the same object
so if we say:
s1.equals(s2) , this will return true.
at the same time , if we say s1==s2 , this will return true.
BUT
if we have
String s1 = "one";
String s2 = new String("one");
now s1 and s2 points to different location in memory (because we forced s2 to be a new string ) , therefore if we say
s1.equals(s2) this will return false
BUT
if we say s1==s2 , this will return true since we are comparing not the object reference, we are comparing the real value that the objects are holding, in both s1 and s2 the have "one".
and finally
if we have
String s1 = "one";
String s2 = new String("two");
and say : s1.equals(s2) , this will return false (because they are 2 different OBJECTS )
and if we say (s1==s2) , this will return false, (because they have different values)
I hope that this is clear now
Maitham
You are having problem with line 18 because the class Test , try to access a private method in class process , even if Test extends Process.
Check out the definition of the private modifier, it will state that if a method or a vairable is declared private it can only be accessed by the class that declares it.
hope that helps
I am using InterBase 6.0
I don't think they support the <rownum> attribute.
anyotherideas??
Hi ,
I need to limit the number of rows returned from the database after executing a query.
for example ,say that i need to see only 5 rows out of my query but the original query returned 30 rows, how can i set this option??
i tried to use the setMaxRows() in the PreparedStatement interface , but it doesn't seems to work , if i use it , i will not get any rows back.
can any one help please.
thanks
Can any one explain the difference between a class method and an instance method.
if you can support it with example , this would be nice.
thanks
Arvind
I have tried your program
it does work ok, both the first and second, and I don't get any
errors at all.
make sure you are not missing out anything somewhere.
I used Jbuilder to compile and run the exact same programs.
and in both of them , they compile and run perfectly with no errors.
that is becuase the method amethod() in class Base, has been overriden by the method amethod() in class RType.
so when we reach the line
Base b = new RType();
the constructor of the super class Base is called first,inside it, a call to the method amethod() is made, remember that this method has been overriden by the subclass, so it will call the overriden version of it, which will be inside the class RType.
so we get "RType.amethod" written to the output.
instead of the "Base.amethod()".
hope this helps