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

Greenhorn
since Mar 28, 2006
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
0
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

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.
14 years ago
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
14 years ago
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
14 years ago
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
14 years ago
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.

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();
}
}
14 years ago
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
14 years ago
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.
14 years ago
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.
14 years ago
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
14 years ago
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>();

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

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

}
}
hope the above code will help
14 years ago
Could any one help me where can i get practice questions for SCJP 1.5 exam and mock exams
15 years ago
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.

Technology : JSP, Servlets along with javascript.

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

Regards,