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

hemadri raju

Greenhorn
+ Follow
since Mar 28, 2006
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 hemadri raju

In order to save memory, two instances of the
following wrapper objects will always be == when their primitive values are the same:
Boolean
Byte
Character from \u0000 to \u007f (7f is 127 in decimal)
Short and Integer from -128 to 127

hope that will help.
And this exception will not arise when are trying to print the same in the first print statement.

So it prints null and then gives an exception
in the statement a3[0]=a3[1]=a3[2]=a2; you are assigning a2 to all the indexes of a3. However a2 have been declared with only as


A[][] a2=new A[2][1]

in which we can refer only as

a3[0 to 2 ][0][0]
and
a3[0 to 2 ][1][0]
code:

hope that will help otherwise it will give array index out of bounds exception
in the statement a3[0]=a3[1]=a3[2]=a2; you are assigning a2 to all the indexes of a3. However a2 have been declared with only as


A[][] a2=new A[2][1]

in which we can refer only as

a3[0 to 2 ][0][0]
and
a3[0 to 2 ][1][0]
code:

hope that will help otherwise it will give array index out of bounds exception
You are actually subclassing the Bar class in when you write the code like Bar{} which can be well understood by executing the following program.

following the sample program with small addition to your code.


public class Foo{
Foo(){System.out.println("foo");}

class Bar{Bar(){System.out.println("bar");}

public void go(){System.out.println("hi");}
}

public static void main(String args[]){
Foo f = new Foo();
f.makeBar();
}
void makeBar(){
(new Bar(){public void go(){System.out.println("hello world");}}).go();
}
}
when you are redifining the function in the child class you are not overloading the base class function, because the base class is having parameter as Object but child class is having parameter as String. So it is not covariant return.

and when you are calling the funciton you are calling using the base class version. so always function of the base class is getting called
whenever we want to have some control over the number of objects to be created for a class.

in such cases we create a private constructor, and static method in that class. and we call the private constructor from that static method. we can have count of objects created for that class using a static variable.
whenever we want to have some control over the number of objects to be created for a class.

in such cases we create a private constructor, and static method in that class. and we call the private constructor from that static method. we can have count of objects created for that class using a static variable.
2 3 and 5 are correct options.

2nd option is correct because Foo has a Baz and intern Baz has Bar which implies that Foo has Bar.

hope this clarifies 2 nd option is also correct
import java.util.*;
class Pet {
String name;
Pet(String name){
this.name=name;
}
public boolean equals(Object o){
return name.equals(((Pet)o).name);
}
public int hashCode(){
return name.length();
}
}
class myComp implements Comparator<Pet>{
public int compare(Pet p1, Pet p2){
return (((Pet)p2).name).compareTo(((Pet)p1).name);
}

}
class TestInts
{
public static void main(String[] args)
{


List<Pet> list=new ArrayList<Pet>();
list.add(new Pet("One"));
list.add(new Pet("Two"));
list.add(new Pet("Three"));
list.add(new Pet("Abc"));

myComp mp=new myComp();
Collections.sort(list,mp);

for(Pet p:list)
System.out.println("::"+p.name);


}
}
hope the above code will help
Could any one help me where can i get practice questions for SCJP 1.5 exam and mock exams
Dear All,

Problem : If a jsp page is taking long time to load(like loading large data from database, comlex database operations etc..) user get frustrated.

What i Need : to display page like loading please wait page...

Technology : JSP, Servlets along with javascript.

Any one of you please help me in this regard.

Regards
hemadri
15 years ago
JSP
Dear Desigan,
Thank you very much for your suggestion. Actually im planning to prepare for scjp exam.

Regards,
Hemadri Raju
Dear all,

Please through some light on SCJP 1.4 and SCJP 1.5 exams which one to go for.... in terms of value, difficulty etc...

Regards,
Hemadri
I want take up SCJP 1.5 Exam. Please let me know the details of Books(preferrably hard copies).

Regards,
Hemadri