Lyn Yang

Greenhorn
+ Follow
since Sep 13, 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 Lyn Yang

Originally posted by Mitch Christensen:
Did you try using Class.isAssignableFrom()?

see (http://download.java.net/jdk6/docs/api/java/lang/Class.html#isAssignableFrom(java.lang.Class))



Thanks, it works!
15 years ago
I have a similar problem but harder. I use java reflection to get back a Class. I need to check whether it is subclass of Collection, therefore I can't use equal to do the checking. I tried the isInstance(), but it doesn't seem to work.

Any advices?

Thanks!
15 years ago

Originally posted by puran.singh:
HI

cong8,

can you tell how we prepare this exam.

how we got confidence.

please tell me.



Well, I think different ppl have different answer for this question.

For me, I really made sure that I understand each topic well and do a lot of mock exams. You can find lots of reading materials in this forum.

K&B book also helped me a lot to understand the topics on 1.4. For the features from Tigger, I read the study guide in http://java.boot.by/scjp-tiger/ and also books on Java 1.5 for the topics that I need more explainations.


Good luck!

Lyn
[ December 13, 2005: Message edited by: Lyn Yang ]
15 years ago

Originally posted by Leonardo Rafaeli:
congratulations lyn

can u ask me a simple question?! (rofl)

in title of question apears the number of correct answers in a single question like the exam of scjp 1.4??? (ex.: choose 3 aswers, like that)

thanks []�s



Yes. It does. But for the drag and drop questions there is no such hint. One answer can be drag into multiple boxes. So, it really test our knowledge.
15 years ago
Thanks!

Noop.. In fact, the result didn't reflect on the screen after the submission. It asked me to print a report then exit. After I got out from the test room, the girl in the test center gave me a very brief report. It only says for different areas what is my score. It didn't even indicate which questions I have done wrong, though I really want to know.
[ December 13, 2005: Message edited by: Lyn Yang ]
15 years ago
Dear all,

I have passed the exam yesterday with a score of 91%. I would like to thank this forum for providing me all the useful materials that help me understand the topics better.

There were at least 10 questions on generics, so make sure you really understand it inside out.
Quite a few questions were on overriding of static methods or methods that uses static member variables.
A few questions on threading too. But I only got 75%, which really surprised me. I thought I will do better.
Enum is also an important topic, it will be good if you can do some hands-on practice. It really helps me.

One complain about the test is the "Task" question, i.e. the drag and drop style. After you click the done and when you try to review it, the previous answers will be GONE.... I gave up and didn't review all the "Task" questions because I think the first instinct will be more accurate.

Also there is plenty of time, do read the questions carefully before you answer. I used 1.5 hours to finish all the questions and 40 mins to review it.

Good luck!

Lyn
[ December 13, 2005: Message edited by: Lyn Yang ]
15 years ago
Thanks, Akshay Kiran. However, what I don't understand is when the overriden (a) operation is used in the subclass i.e.
public int doIt(String str, Integer[] data)

However, I think I know the answer when I tried to reorganize the question. I got myself confused as I messed up the overidden (a) and overriden(b)

When the overriden (a) is used, the OneSubclass.doIt(String str, Integer[] data) is not a vararg, so it is expecting an array. Therefore, the 1, 2, 3, 5, 7 will call the OneSuperclass.doIt(String str, Number... data).

B.T.W. Your summary of how compiler works is very clear and precise. Thank you.
no answer?

Somebody please help...
Hi,

I am reading the SCJP Tiger Study Guide, I don't quite follow how the overriding with varargs works on the example given. Please help me out.

public class OneSuperclass {
public int doIt(String str, Integer... data) throws java.io.EOFException,
java.io.FileNotFoundException { // (1)
String signature = "(String, Integer[])";
out.println(str + " => " + signature);
return 1;
}

public void doIt(String str, Number... data) { // (2)
String signature = "(String, Number[])";
out.println(str + " => " + signature);
}
}

import static java.lang.System.out;

public class OneSubclass extends OneSuperclass {

public int doIt(String str, Integer[] data) // Overridden (a)
//public int doIt(String str, Integer... data) // Overridden (b)

throws java.io.FileNotFoundException {
String signature = "(String, Integer[])";
out.println("Overridden: " + str + " => " + signature);
return 0;
}

public void doIt(String str, Object... data) { // Overloading
String signature = "(String, Object[])";
out.println(str + " => " + signature);
}

public static void main(String[] args) throws Exception {
OneSubclass ref = new OneSubclass();
ref.doIt("1. (String)");
ref.doIt("2. (String, int)", 10);
ref.doIt("3. (String, Integer)", new Integer(10));
ref.doIt("4. (String, int, byte)", 10, (byte) 20);
ref.doIt("5. (String, int, int)", 10, 20);
ref.doIt("6. (String, int, long)", 10, 20L);
ref.doIt("7. (String, int, int, int)", 10, 20, 30);
ref.doIt("8. (String, int, double)", 10, 20.0);
ref.doIt("9. (String, int, String)", 10, "what?");
ref.doIt("10.(String, boolean)", false);
}
}

It says that with overriden(a), the output will be the following:
1. (String) => (String, Number[])
2. (String, int) => (String, Number[])
3. (String, Integer) => (String, Number[])
4. (String, int, byte) => (String, Number[])
5. (String, int, int) => (String, Number[])
6. (String, int, long) => (String, Number[])
7. (String, int, int, int) => (String, Number[])
8. (String, int, double) => (String, Number[])
9. (String, int, String) => (String, Object[])
10.(String, boolean) => (String, Object[])

But with overriden (b), the output is:
Overridden: 1. (String) => (String, Integer[])
Overridden: 2. (String, int) => (String, Integer[])
Overridden: 3. (String, Integer) => (String, Integer[])
4. (String, int, byte) => (String, Number[])
Overridden: 5. (String, int, int) => (String, Integer[])
6. (String, int, long) => (String, Number[])
Overridden: 7. (String, int, int, int) => (String, Integer[])
8. (String, int, double) => (String, Number[])
9. (String, int, String) => (String, Object[])
10.(String, boolean) => (String, Object[])

My doubt is:
For output statment 1, 2, 3, 5, 7, When overriden (a) is used, why the OneSuperclass.doIt(String str, Number... data) operation is chosen? Why not OneSubclass.doIt(String str, Integer... data)? Isn't the signature of OneSubclass.doIt(String str, Integer... data) is more matching with the input parameter?

Thanks!


Lyn
[ October 02, 2005: Message edited by: Lyn Yang ]
To my understading, as long as a method is declared as public, all the subclasses inherit it.

I tried to run the above code, and "Sub" was printed. No exception was thrown :roll:

How did you run the code?

I just use:
java Test
I think the answer should be 10. Because there is a " " in the println. That is is why I think the println statement has 2 string objects created.
My answer is also 10

String s1 = "spring"; ->+1
String s2 = s1+"summer"; ->+2
s1.concat("fall"); ->+2
s1.concat(s2); ->+1
s1+="winter"; -->+2
System.out.println(s1+" "+s2); ->+2
------------------------------------------
Total: 10 ??