Win a copy of High Performance Python for Data Analytics this week in the Python forum!

Fes D Gaur

Ranch Hand
+ Follow
since Apr 29, 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 Fes D Gaur

Hey folks,

I finally took the SCJP 1.4 today and passed it with an 83% . I had been studying off and on for a while now. I would have taken the 1.5 exam except when I started studying there wasn't enough material for 1.5. Anyhow here are a few things I would like to share with you:

About The Exam:

1. The exam seemed a bit harder than I expected. Some of it was probably exam anxiety. But a fair warning is that most of the questions on the exam are not a cake walk. To relieve exam anxiety there are some good tips on the Prometric site: http://www.2test.com

2. The exam software was pretty good. The questions were very readable and it was easy to navigate.

3. There was plenty of time to finish the exam. I had about 29 minutes when I completed all 61 questions. Then I revised all the questions in the remaining time.

4. Because of the complexity of the exam I didn't know I had passed till the end of the exam. Even then it didn't say that I had passed. Instead it gave me a section analysis which is a breakdown in percentage of the different sections on the exam. When I left the exam room and got the report from the administrator then the report showed that I had passed.

5. I was surprised that I had not done as well on some sections that I believed I was strong in and scored well on other sections where I thought I was a little weak. For example I thought I was strong in the Garbage collection section and got a 66%. But I got a 100% in other sections like collections framework, flow control, assertions and others.

6. One grievance I have with the testing center is that they gave me a plastic worksheet with two markers and an eraser. The markers were both dry and their tips were like brushes. When I finished the exam I told the administrator and all she said was that "yes, they are cheap markers".

The Preparation:

1. I read the K&B book and took all the self tests. First time around I didn't get very high scores. So I re-read the book and took all the self tests again. I did a lot better. So don't get discouraged if you don't do well on tests in the beginning stages of your preparation.

2. I took plenty of mock exams mentioned on the Javaranch site. Questions on most of the mock exams aren't like the actual exam in terms of complexity and format. Some mock tests had incorrect answers as well. Still mock exams are excellent for preparing for the exam and you should take them to improve the overall understanding of the various topics.

3. The 3 Marcus exams and the Java 1.4 application on Marcus's site all are pretty good. I took 2 exams a few weeks before I took the exam and I took the third exam in the last week. The score on these exams is a good reflection on how you will score on the actual exam.

4. Two days before the exam I took both the Master Exams from the K&B book. The Master Exam on the CD has a lot of questions from the book. So if you've taken the self tests a couple of times this exam is a good revision but won't really give you a fair idea of how you'll score on the actual exam. This is why I downloaded the second Master Exam and took it.

5. Finally, actively participate in the posts on the Javaranch forum. It helps a lot.

Exam Tips:

1. Do lots of mock exams. The help take away a lot of exam anxiety and help you become better test takers.

2. Read the question carefully.

3. In questions where some lines of code is given try to read the answer choices. If the choices have "Compilation error", then read all lines of code carefully. If it doesn't then don't worry about the syntax of the code and work on the solution. This will help save time.

4. When you finish the exam revise all your answers. You will be tempted to change some answers. But be careful about this because you may be over thinking the solution and end up making a mistake. Nevertheless, the revision is still a good idea.

Well that's all my feedback on the exam for now. Thanks to everyone on the javaranch site. Keep up the good work guys.

Thank You,

Fes
15 years ago
1. How many objects are eligible for garbage collection once execution has reached the line labeled Line A?

String name;
String newName = "Nick";
newName = "Jason";
name = "Frieda";

String newestName = name;

name = null;
//Line A

a) 0
b) 1
c) 2
d) 3
e) 4


2. Which of the following statements about Java's garbage collection are true?

a) The garbage collector can be invoked explicitly using a Runtime object.
b) The finalize method is always called before an object is garbage collected.
c) Any class that includes a finalize method should invoke its superclass' finalize method.
d) Garbage collection behavior is very predictable.

I think the answers are
1.a (0) String literal pool will be referring to all objects
2.b finalise method has to be called atleast once ..

Here's my take on it:

Question 1: There is one object that is eligible for Gargbage collection. That object is "Nick". The newName reference first refers to "Nick" and then points to "Jason" leaving "Nick" without a reference and making it eligible for Garbage Collection. All other objects have references.

Question 2. I think the correct answer is b. One of the very few guarantees the Garbage Collection in Java provides is that before an object is garbage collected its finalize method (if it has one) will be invoked. I don't know of any runtime object that is used to explicitely make GC run. I don't think you need to call a super class if you have a finalize method in your class. Lastly GC behavior is by no means predictable.
This is from Marcus Exam 3:

Which of the following are valid statements

1) public class MyCalc extends Math
2) Math.max(s);
3) Math.round(9.99,1);
4)Math.mod(4,10);

Answer: None of these are valid statements. The Math class is final and cannot be extended. The max method takes two parameters, round only takes one parameter and there is no mod parameter. You may get questions in the exam that have no apparently correct answer. If you are absolutely sure this is the case, do not check any of the options.

Does the 1.4 exam have questions where none of the options are correct and should we leave the question without checking any of the options? I have not heard of this before. Could someone please shed some light.

Thanks,
Fes
I got this question from Bary Boon's mock exam.

Q 65. Which statements about Garbage Collection are true?

Select all valid answers:
a. You can directly free the memory allocated by an object.
b. You can directly run the garbage collector whenever you want to and it will be schedule in due time..
c. The garbage collector informs your object when it is about to be garbage collected.
d. The garbage collector reclaims an object´┐Żs memory as soon as it becomes a candidate for garbage collection.
e. The garbage collector runs in low-memory situations.

The answer given is b,c,e.

The exam was created before JVM 1.4. So I'm pretty sure that b is not correct. I think e is correct. How about c?

Thanks,
Fes
When you speak of delegation you could be speaking of one of two things:

1. The Delegate design pattern
http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html

2. Microsoft's use of delegate in .NET where multipe methods can be called through calling one method using method signature.

http://www.15seconds.com/issue/020815.htm

Hope this helps
Fes
So if you fail on the exam once do you have to purchase another voucher from Sun to sit for the exam again? Or can you use the same voucher for a maximum of three tries that same year?

Thanks,
Fes
Thanks Guys, I got it. Wow! so even if there is an addValue method in base the addValue method of the Derived class is being called because the object belongs to the Derived class. I'll have to watch out for this.

Fes
Maybe my brain cells are just a little dead today, but how is following code producing 40 and not 30?

class Base{
int value = 0;
Base(){
addValue();
}
void addValue(){
value += 10;
}
int getValue(){
return value;
}
}
class Derived extends Base{
Derived(){
addValue();
}
void addValue(){
value += 20;
}
}
public class ValTest {
public static void main(String[] args){
Base b = new Derived();
System.out.println(b.getValue());
}
}

Thanks,
Fes
The following code is legal and compiles

public class CastTest{
public static void main(String r[]){
byte b = (int)(long)(byte)(char)(short)(float)(double) 16.2;
System.out.println(b);
}
}

Can someone explain the rule for casting here? Is the rule that if it is a numeric type it can be cast to a primitive with higher or lower bits?

Thanks,
Fes
Which of the following statements is true?

a) An interface can contain a nested top-level inner class.

b) An interface can contain a member inner class.

c) A member inner class can implement an interface.

d) A static method can contain a local class.

e) A static method can contain a nested top-level class.


I think b,c, and d are correct:

public interface TopInterface{
public class InnerClass{
InnerClass(){
System.out.println("Hi");
}
public static void main(String r[]){
InnerClass in = new InnerClass();
}
}

}

Also

public class StaticInner{
public static void StaticMethod(){
class LocalClass{

}
}
}

Please let me know if this is wrong.

Thanks,
Fes
For the following code:

public class Test15{
public static void method(StringBuffer sb){
sb.append(" Added");
sb = new StringBuffer("Hai");
}
public static void main(String a[]){
StringBuffer sb = new StringBuffer("String Buffer");
method(sb);
System.out.println(sb);
}
}

The output is String Buffer Added

Can someone please explain why?

Thanks,
Fes
A Mock test had the question:

Which of the following will definitely stop a thread from executing?

yield() was one of the answers. I know that yield() sends control back to the JVM and the JVM may pick up the same thread and start it again. So this questions is somewhat confusing. Could a question like this come on the Test?

Thanks,
Fes
I don't think I agree that the first object created to which x is referring is eligible for garbage collection. Java is a pass by value language. This is not only true for primitives but also for references in that only a copy of the value of refences is passed to methods. So the original reference x will still refer to the original object created on the first line.

The object to which x2 is referring may be eligible for GC. An object is created in the method and copy of the value of its reference is passed to x2. At the end of the main method x2 starts referring to the first object leaving no references for the second object.

Please let me know what you think.

Thanks,
Fes
Thanks for the response guys. I know now that the inherited methods should also be looked at. But one thing I don't understand, why does the statement

System.out.println(sb1.equals.sb2);

return false. Doesn't equals check if the two objects are meaningfully equal instead of comparing their reference like "==" does?

Thanks,
Fes
In the following code


StringBuffer sb1 = new StringBuffer("abcd");
StringBuffer sb2 = new StringBuffer("abcd");
System.out.println(sb1.equals(sb2));

The above code compiles. Does the StringBuffer class override equals() ? If not then why doesn't the compiler give and error at sb1.equals(sb2) ??

Thanks,

Fes