Alexey Korneychuk

Greenhorn
+ Follow
since Sep 06, 2005
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 Alexey Korneychuk

Hello ranchers!
new exam includes scenario-based questions but old exam - don't.
I don't get such type of question.
Could anyone tell me what is it?
Thanks
<role-name>member</role-name>
May be you want tell manager?
I think you should try

<security-role>
<role-name>admin</role-name>
</security-role>
<security-role>
<role-name>admin</role-name>
</security-role>
Hi
These methods since 2.4 (not 2.3)
Are you sure that you are using 2.4 servlet spec?
You are using BOTH <jsp-file>/test2.jsp</jsp-file>
and <servlet-class>test</servlet-class>.
It's wrong.

The Strng dwe variable was declared in public void jspInit().
So You cannot use <%= dwe %>.
Hello, ranches!

Why does run-time exception occur?
What is the difference between Hashtable and HashMap classes?

public class J {

public static void main(String[] args) throws Exception {
HashMap hm = new HashMap();
hm.put(null, null);
System.out.println(hm);

Thread.sleep(1000);

Hashtable ht = new Hashtable();
ht.put(null, null);
System.out.println(ht);


}
}

Result:
{null=null}
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:397)
at fgff.Jhsdhdjshdjhsdjhjhjsdhjs.main(J.java:28)
Exception in thread "main"

Alexey
Hello, ranches!

What is tightly encapsulated class?

Have you any GOOD links about this topic?

Does the exam have any questions of this type?

Alexey
int abs(int x) {
if (x >= 0) return x;
else return -x;
}


-x == ~x + 1
Integer.MINVALUE = 10....0 (binary)
So
-10...0 = ~10...0 + 1 = 01.....1 + 1 = 10000000 = Integer.MINVALUE

Hence -Integer.MINVALUE = Integer.MINVALUE
and Math.abs(Integer.MINVALUE) = Integer.MINVALUE

PS
public class K {

public static void main(String[] args) {
int i = Integer.MIN_VALUE;
System.out.println(i);
System.out.println(-i);
System.out.println(Math.abs(i));
}
}
-2147483648
-2147483648
-2147483648

Alexey
I think
{byte b = (byte) f;} the same { byte b = (byte) (int)f;}

But not sure
Hello everybody!

What wiil be output and why?
What kind of intern (); method?


public class Lsdksdksdjkjksdkdjdsjdkjkjsdkjsdk {

public static void main(String[] args) {
String s1 = "JavaWorld";
String s2 = ("Java" + new String ("World")).intern ();
System.out.println(s1);
System.out.println(s2);
System.out.println(s2 == s1);
}
}
I use WHIZLabs SCJP 1.4 Simulator Version 4.0.0 for preparing to exam.
But today I found bug in practice exam 6 (question 30).


Where I can find bug list about this simulator?
Help me, please.

Thanks, Alexey
Do not use == with float(double) variable

public class class22 {

public static void main(String[] args) {

double f = 12.3f;
System.out.println(f);
if (f == 12.3) {
System.out.println("Equal");
} else {
System.out.println("Unequal");
}

}
}

12.300000190734863
Unequal
With J2SDK1.4.2. the same.
But
I use WebSphere Studio Application Developer (Windows)
Version: 5.1.2

String10
String9
String8
String7
String6
String5
String4
String3
String2
String1
String0
End
GC String1
GC String10
GC String9
GC String8
GC String7
GC String6
GC String5
GC String4
GC String3
GC String2

"GC String0" I did't find in folowing list!
What is mind?
Excuse me for my mistake!
I thought correct answer is 11 becouse count of iterate is 11.
But correct answer is 10. Last String object do not eligible for garbage collection. Why?
Hello, all!

When the program reaches line 8, how many String objects are eligible for garbage collection?
10 or 11?
I thought 10, but correct answer is 11! Why?

1: public class Jskdkdkkd {
2:
3:public static void main(String[] args) {
4:for (int i = 10; i >= 0; --i) {
5:String s = new String("String") + i;
6:System.out.println(s);
7:}
8:System.out.println("End");
9:}
10: }